| author | wenzelm |
| Tue, 16 Sep 2025 12:06:07 +0200 | |
| changeset 83167 | 84b092fd0f7a |
| parent 83165 | 9f3f723938fc |
| child 83169 | f009f8ac4de1 |
| permissions | -rw-r--r-- |
| 68758 | 1 |
/* Title: Pure/PIDE/document_status.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Document status based on markup information. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
| 75393 | 10 |
object Document_Status {
|
| 83161 | 11 |
/* theory status: via 'theory' or 'end' commands */ |
12 |
||
13 |
object Theory_Status extends Enumeration {
|
|
14 |
val NONE, INITIALIZED, FINALIZED, CONSOLIDATING, CONSOLIDATED = Value |
|
15 |
||
16 |
def initialized(t: Value): Boolean = t >= INITIALIZED |
|
17 |
def finalized(t: Value): Boolean = t >= FINALIZED |
|
18 |
def consolidating(t: Value): Boolean = t >= CONSOLIDATING |
|
19 |
def consolidated(t: Value): Boolean = t >= CONSOLIDATED |
|
20 |
||
21 |
def merge(t1: Value, t2: Value): Value = if (t1 >= t2) t1 else t2 |
|
22 |
} |
|
23 |
||
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
24 |
trait Theory_Status {
|
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
25 |
def theory_status: Theory_Status.Value |
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
26 |
def initialized: Boolean = Theory_Status.initialized(theory_status) |
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
27 |
def finalized: Boolean = Theory_Status.finalized(theory_status) |
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
28 |
def consolidating: Boolean = Theory_Status.consolidating(theory_status) |
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
29 |
def consolidated: Boolean = Theory_Status.consolidated(theory_status) |
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
30 |
} |
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
31 |
|
| 83161 | 32 |
|
| 68758 | 33 |
/* command status */ |
34 |
||
| 75393 | 35 |
object Command_Status {
|
| 68758 | 36 |
val proper_elements: Markup.Elements = |
37 |
Markup.Elements(Markup.ACCEPTED, Markup.FORKED, Markup.JOINED, Markup.RUNNING, |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
38 |
Markup.FINISHED, Markup.FAILED, Markup.CANCELED) |
| 68758 | 39 |
|
40 |
val liberal_elements: Markup.Elements = |
|
41 |
proper_elements + Markup.WARNING + Markup.LEGACY + Markup.ERROR |
|
42 |
||
| 83157 | 43 |
def make( |
44 |
markups: Iterable[Markup], |
|
45 |
warned: Boolean = false, |
|
46 |
failed: Boolean = false |
|
47 |
): Command_Status = {
|
|
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
48 |
var theory_status = Theory_Status.NONE |
| 68758 | 49 |
var touched = false |
50 |
var accepted = false |
|
| 83157 | 51 |
var warned1 = warned |
52 |
var failed1 = failed |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
53 |
var canceled = false |
| 68758 | 54 |
var forks = 0 |
55 |
var runs = 0 |
|
| 83155 | 56 |
for (markup <- markups) {
|
| 68758 | 57 |
markup.name match {
|
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
58 |
case Markup.INITIALIZED => |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
59 |
theory_status = Theory_Status.merge(theory_status, Theory_Status.INITIALIZED) |
|
83160
bc86832bd2fd
clarified Theory_Status.FINALIZED: it belongs to this linear row, too;
wenzelm
parents:
83158
diff
changeset
|
60 |
case Markup.FINALIZED => |
|
bc86832bd2fd
clarified Theory_Status.FINALIZED: it belongs to this linear row, too;
wenzelm
parents:
83158
diff
changeset
|
61 |
theory_status = Theory_Status.merge(theory_status, Theory_Status.FINALIZED) |
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
62 |
case Markup.CONSOLIDATING => |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
63 |
theory_status = Theory_Status.merge(theory_status, Theory_Status.CONSOLIDATING) |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
64 |
case Markup.CONSOLIDATED => |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
65 |
theory_status = Theory_Status.merge(theory_status, Theory_Status.CONSOLIDATED) |
| 68758 | 66 |
case Markup.ACCEPTED => accepted = true |
67 |
case Markup.FORKED => touched = true; forks += 1 |
|
68 |
case Markup.JOINED => forks -= 1 |
|
69 |
case Markup.RUNNING => touched = true; runs += 1 |
|
70 |
case Markup.FINISHED => runs -= 1 |
|
| 83157 | 71 |
case Markup.WARNING | Markup.LEGACY => warned1 = true |
72 |
case Markup.FAILED | Markup.ERROR => failed1 = true |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
73 |
case Markup.CANCELED => canceled = true |
| 68758 | 74 |
case _ => |
75 |
} |
|
76 |
} |
|
| 83155 | 77 |
new Command_Status( |
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
78 |
theory_status = theory_status, |
| 68887 | 79 |
touched = touched, |
80 |
accepted = accepted, |
|
| 83157 | 81 |
warned = warned1, |
82 |
failed = failed1, |
|
| 68887 | 83 |
canceled = canceled, |
84 |
forks = forks, |
|
85 |
runs = runs) |
|
| 68758 | 86 |
} |
87 |
||
| 83155 | 88 |
val empty: Command_Status = make(Nil) |
| 68758 | 89 |
|
|
83156
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
90 |
def merge(args: IterableOnce[Command_Status]): Command_Status = |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
91 |
args.iterator.foldLeft(empty)(_ + _) |
| 68758 | 92 |
} |
93 |
||
| 83155 | 94 |
final class Command_Status private( |
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
95 |
val theory_status: Theory_Status.Value, |
| 68758 | 96 |
private val touched: Boolean, |
97 |
private val accepted: Boolean, |
|
98 |
private val warned: Boolean, |
|
99 |
private val failed: Boolean, |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
100 |
private val canceled: Boolean, |
| 83155 | 101 |
val forks: Int, |
102 |
val runs: Int |
|
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
103 |
) extends Theory_Status {
|
| 83155 | 104 |
override def toString: String = |
|
83156
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
105 |
if (is_empty) "Command_Status.empty" |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
106 |
else if (failed) "Command_Status(failed)" |
| 83155 | 107 |
else if (warned) "Command_Status(warned)" |
|
83156
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
108 |
else "Command_Status(...)" |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
109 |
|
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
110 |
def is_empty: Boolean = |
| 83161 | 111 |
!Theory_Status.initialized(theory_status) && |
|
83160
bc86832bd2fd
clarified Theory_Status.FINALIZED: it belongs to this linear row, too;
wenzelm
parents:
83158
diff
changeset
|
112 |
!touched && !accepted && !warned && !failed && !canceled && |
|
83156
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
113 |
forks == 0 && runs == 0 |
| 83155 | 114 |
|
| 68758 | 115 |
def + (that: Command_Status): Command_Status = |
|
83156
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
116 |
if (is_empty) that |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
117 |
else if (that.is_empty) this |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
118 |
else {
|
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
119 |
new Command_Status( |
| 83161 | 120 |
theory_status = Theory_Status.merge(theory_status, that.theory_status), |
|
83156
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
121 |
touched = touched || that.touched, |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
122 |
accepted = accepted || that.accepted, |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
123 |
warned = warned || that.warned, |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
124 |
failed = failed || that.failed, |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
125 |
canceled = canceled || that.canceled, |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
126 |
forks = forks + that.forks, |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
127 |
runs = runs + that.runs) |
|
6bc5835bc794
clarified signature, following e.g. Command.Markups;
wenzelm
parents:
83155
diff
changeset
|
128 |
} |
| 68758 | 129 |
|
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
130 |
def maybe_consolidated: Boolean = touched && forks == 0 && runs == 0 |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
131 |
|
| 68758 | 132 |
def is_unprocessed: Boolean = accepted && !failed && (!touched || (forks != 0 && runs == 0)) |
133 |
def is_running: Boolean = runs != 0 |
|
134 |
def is_warned: Boolean = warned |
|
135 |
def is_failed: Boolean = failed |
|
136 |
def is_finished: Boolean = !failed && touched && forks == 0 && runs == 0 |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
137 |
def is_canceled: Boolean = canceled |
| 68881 | 138 |
def is_terminated: Boolean = canceled || touched && forks == 0 && runs == 0 |
| 68758 | 139 |
} |
140 |
||
141 |
||
142 |
/* node status */ |
|
143 |
||
| 75393 | 144 |
object Node_Status {
|
| 83167 | 145 |
val empty: Node_Status = Node_Status() |
|
76716
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
146 |
|
| 68758 | 147 |
def make( |
148 |
state: Document.State, |
|
149 |
version: Document.Version, |
|
| 76714 | 150 |
name: Document.Node.Name |
151 |
): Node_Status = {
|
|
| 68758 | 152 |
val node = version.nodes(name) |
153 |
||
154 |
var unprocessed = 0 |
|
155 |
var running = 0 |
|
156 |
var warned = 0 |
|
157 |
var failed = 0 |
|
158 |
var finished = 0 |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
159 |
var canceled = false |
| 68892 | 160 |
var terminated = true |
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
161 |
var theory_status = Document_Status.Theory_Status.NONE |
| 68758 | 162 |
for (command <- node.commands.iterator) {
|
| 83164 | 163 |
val status = state.command_status(version, command) |
| 68758 | 164 |
|
165 |
if (status.is_running) running += 1 |
|
166 |
else if (status.is_failed) failed += 1 |
|
167 |
else if (status.is_warned) warned += 1 |
|
168 |
else if (status.is_finished) finished += 1 |
|
169 |
else unprocessed += 1 |
|
|
68871
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
170 |
|
|
f5c76072db55
more explicit status for "canceled" command within theory node;
wenzelm
parents:
68770
diff
changeset
|
171 |
if (status.is_canceled) canceled = true |
| 68892 | 172 |
if (!status.is_terminated) terminated = false |
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
173 |
|
|
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
174 |
theory_status = Theory_Status.merge(theory_status, status.theory_status) |
| 68758 | 175 |
} |
176 |
||
| 68887 | 177 |
Node_Status( |
| 83163 | 178 |
suppressed = version.nodes.suppressed(name), |
| 68887 | 179 |
unprocessed = unprocessed, |
180 |
running = running, |
|
181 |
warned = warned, |
|
182 |
failed = failed, |
|
183 |
finished = finished, |
|
184 |
canceled = canceled, |
|
185 |
terminated = terminated, |
|
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
186 |
theory_status = theory_status) |
| 68758 | 187 |
} |
188 |
} |
|
189 |
||
190 |
sealed case class Node_Status( |
|
| 83167 | 191 |
suppressed: Boolean = false, |
192 |
unprocessed: Int = 0, |
|
193 |
running: Int = 0, |
|
194 |
warned: Int = 0, |
|
195 |
failed: Int = 0, |
|
196 |
finished: Int = 0, |
|
197 |
canceled: Boolean = false, |
|
198 |
terminated: Boolean = false, |
|
199 |
theory_status: Theory_Status.Value = Theory_Status.NONE |
|
|
83165
9f3f723938fc
more uniform Command_Status.theory_status vs. Node_Status.theory_status: cover all command_states, without special cases;
wenzelm
parents:
83164
diff
changeset
|
200 |
) extends Theory_Status {
|
|
76716
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
201 |
def is_empty: Boolean = this == Node_Status.empty |
|
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
202 |
|
| 68758 | 203 |
def ok: Boolean = failed == 0 |
204 |
def total: Int = unprocessed + running + warned + failed + finished |
|
205 |
||
| 83163 | 206 |
def quasi_consolidated: Boolean = !suppressed && !finalized && terminated |
| 68897 | 207 |
|
| 68898 | 208 |
def percentage: Int = |
209 |
if (consolidated) 100 |
|
210 |
else if (total == 0) 0 |
|
211 |
else (((total - unprocessed).toDouble / total) * 100).toInt min 99 |
|
212 |
||
| 68758 | 213 |
def json: JSON.Object.T = |
214 |
JSON.Object("ok" -> ok, "total" -> total, "unprocessed" -> unprocessed,
|
|
215 |
"running" -> running, "warned" -> warned, "failed" -> failed, "finished" -> finished, |
|
| 68898 | 216 |
"canceled" -> canceled, "consolidated" -> consolidated, |
217 |
"percentage" -> percentage) |
|
| 68758 | 218 |
} |
219 |
||
220 |
||
| 69863 | 221 |
/* overall timing */ |
| 68758 | 222 |
|
| 75393 | 223 |
object Overall_Timing {
|
| 83154 | 224 |
val empty: Overall_Timing = Overall_Timing() |
| 68758 | 225 |
|
226 |
def make( |
|
227 |
state: Document.State, |
|
228 |
version: Document.Version, |
|
| 69863 | 229 |
commands: Iterable[Command], |
| 75393 | 230 |
threshold: Double = 0.0 |
231 |
): Overall_Timing = {
|
|
| 68758 | 232 |
var total = 0.0 |
| 69863 | 233 |
var command_timings = Map.empty[Command, Double] |
| 68758 | 234 |
for {
|
| 69863 | 235 |
command <- commands.iterator |
| 68758 | 236 |
st <- state.command_states(version, command) |
237 |
} {
|
|
238 |
val command_timing = |
|
| 73359 | 239 |
st.status.foldLeft(0.0) {
|
| 68758 | 240 |
case (timing, Markup.Timing(t)) => timing + t.elapsed.seconds |
241 |
case (timing, _) => timing |
|
| 73359 | 242 |
} |
| 68758 | 243 |
total += command_timing |
| 69864 | 244 |
if (command_timing > 0.0 && command_timing >= threshold) {
|
245 |
command_timings += (command -> command_timing) |
|
246 |
} |
|
| 68758 | 247 |
} |
| 83154 | 248 |
Overall_Timing(total = total, command_timings = command_timings) |
| 68758 | 249 |
} |
250 |
} |
|
251 |
||
| 83154 | 252 |
sealed case class Overall_Timing( |
253 |
total: Double = 0.0, |
|
254 |
command_timings: Map[Command, Double] = Map.empty |
|
255 |
) {
|
|
| 69864 | 256 |
def command_timing(command: Command): Double = |
257 |
command_timings.getOrElse(command, 0.0) |
|
258 |
} |
|
| 68759 | 259 |
|
260 |
||
261 |
/* nodes status */ |
|
262 |
||
| 78600 | 263 |
enum Overall_Node_Status { case ok, failed, pending }
|
| 68759 | 264 |
|
| 75393 | 265 |
object Nodes_Status {
|
| 68903 | 266 |
val empty: Nodes_Status = new Nodes_Status(Map.empty, Document.Nodes.empty) |
| 68759 | 267 |
} |
268 |
||
| 68903 | 269 |
final class Nodes_Status private( |
270 |
private val rep: Map[Document.Node.Name, Node_Status], |
|
| 75393 | 271 |
nodes: Document.Nodes |
272 |
) {
|
|
|
68770
add44e2b8cb0
optional notification of nodes_status (via progress);
wenzelm
parents:
68769
diff
changeset
|
273 |
def is_empty: Boolean = rep.isEmpty |
|
add44e2b8cb0
optional notification of nodes_status (via progress);
wenzelm
parents:
68769
diff
changeset
|
274 |
def apply(name: Document.Node.Name): Node_Status = rep(name) |
| 68759 | 275 |
def get(name: Document.Node.Name): Option[Node_Status] = rep.get(name) |
276 |
||
|
76716
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
277 |
def present( |
|
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
278 |
domain: Option[List[Document.Node.Name]] = None |
|
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
279 |
): List[(Document.Node.Name, Node_Status)] = {
|
|
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
280 |
for (name <- domain.getOrElse(nodes.topological_order)) |
|
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
281 |
yield name -> get(name).getOrElse(Node_Status.empty) |
|
a7602257a825
clarified state document nodes for Theories_Status / Document_Dockable;
wenzelm
parents:
76714
diff
changeset
|
282 |
} |
| 68903 | 283 |
|
|
68884
9b97d0b20d95
clarified quasi_consolidated state: ensure that exports are present for ok nodes;
wenzelm
parents:
68883
diff
changeset
|
284 |
def quasi_consolidated(name: Document.Node.Name): Boolean = |
|
68883
3653b3ad729e
clarified Thy_Resources.Session.use_theories: "terminated" node status is sufficient;
wenzelm
parents:
68881
diff
changeset
|
285 |
rep.get(name) match {
|
| 68897 | 286 |
case Some(st) => st.quasi_consolidated |
|
68883
3653b3ad729e
clarified Thy_Resources.Session.use_theories: "terminated" node status is sufficient;
wenzelm
parents:
68881
diff
changeset
|
287 |
case None => false |
|
3653b3ad729e
clarified Thy_Resources.Session.use_theories: "terminated" node status is sufficient;
wenzelm
parents:
68881
diff
changeset
|
288 |
} |
|
3653b3ad729e
clarified Thy_Resources.Session.use_theories: "terminated" node status is sufficient;
wenzelm
parents:
68881
diff
changeset
|
289 |
|
| 78600 | 290 |
def overall_node_status(name: Document.Node.Name): Overall_Node_Status = |
| 68759 | 291 |
rep.get(name) match {
|
292 |
case Some(st) if st.consolidated => |
|
293 |
if (st.ok) Overall_Node_Status.ok else Overall_Node_Status.failed |
|
294 |
case _ => Overall_Node_Status.pending |
|
295 |
} |
|
296 |
||
| 68763 | 297 |
def update( |
|
69255
800b1ce96fce
more general support for Isabelle/PIDE file formats -- less hardwired Bibtex operations;
wenzelm
parents:
68904
diff
changeset
|
298 |
resources: Resources, |
| 68763 | 299 |
state: Document.State, |
300 |
version: Document.Version, |
|
| 68769 | 301 |
domain: Option[Set[Document.Node.Name]] = None, |
| 75393 | 302 |
trim: Boolean = false |
303 |
): (Boolean, Nodes_Status) = {
|
|
| 68903 | 304 |
val nodes1 = version.nodes |
| 68763 | 305 |
val update_iterator = |
306 |
for {
|
|
| 68903 | 307 |
name <- domain.getOrElse(nodes1.domain).iterator |
| 82918 | 308 |
if !Resources.hidden_node(name) && !resources.loaded_theory(name) |
| 68763 | 309 |
st = Document_Status.Node_Status.make(state, version, name) |
310 |
if !rep.isDefinedAt(name) || rep(name) != st |
|
311 |
} yield (name -> st) |
|
312 |
val rep1 = rep ++ update_iterator |
|
| 68903 | 313 |
val rep2 = if (trim) rep1 -- rep1.keysIterator.filterNot(nodes1.domain) else rep1 |
| 68764 | 314 |
|
| 68903 | 315 |
(rep != rep2, new Nodes_Status(rep2, nodes1)) |
| 68763 | 316 |
} |
| 68761 | 317 |
|
| 68759 | 318 |
override def hashCode: Int = rep.hashCode |
319 |
override def equals(that: Any): Boolean = |
|
320 |
that match {
|
|
321 |
case other: Nodes_Status => rep == other.rep |
|
322 |
case _ => false |
|
323 |
} |
|
| 68765 | 324 |
|
| 75393 | 325 |
override def toString: String = {
|
| 68765 | 326 |
var ok = 0 |
327 |
var failed = 0 |
|
328 |
var pending = 0 |
|
| 68873 | 329 |
var canceled = 0 |
| 68765 | 330 |
for (name <- rep.keysIterator) {
|
331 |
overall_node_status(name) match {
|
|
332 |
case Overall_Node_Status.ok => ok += 1 |
|
333 |
case Overall_Node_Status.failed => failed += 1 |
|
334 |
case Overall_Node_Status.pending => pending += 1 |
|
335 |
} |
|
| 68873 | 336 |
if (apply(name).canceled) canceled += 1 |
| 68765 | 337 |
} |
| 68873 | 338 |
"Nodes_Status(ok = " + ok + ", failed = " + failed + ", pending = " + pending + |
339 |
", canceled = " + canceled + ")" |
|
| 68765 | 340 |
} |
| 68759 | 341 |
} |
| 68758 | 342 |
} |