| author | wenzelm |
| Tue, 04 Nov 2025 20:11:15 +0100 | |
| changeset 83503 | 7b1b7ac616c0 |
| parent 83297 | 00bb83e60336 |
| permissions | -rw-r--r-- |
| 36676 | 1 |
/* Title: Pure/PIDE/command.scala |
2 |
Author: Fabian Immler, TU Munich |
|
3 |
Author: Makarius |
|
4 |
||
| 52536 | 5 |
Prover commands with accumulated results from execution. |
| 36676 | 6 |
*/ |
| 34407 | 7 |
|
|
34871
e596a0b71f3c
incorporate "proofdocument" part into main Isabelle/Pure.jar -- except for html_panel.scala, which depends on external library (Lobo/Cobra browser);
wenzelm
parents:
34865
diff
changeset
|
8 |
package isabelle |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
|
| 34451 | 10 |
|
| 38872 | 11 |
import scala.collection.immutable.SortedMap |
12 |
||
13 |
||
| 75393 | 14 |
object Command {
|
| 72814 | 15 |
/* blobs */ |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
16 |
|
| 72745 | 17 |
sealed case class Blob( |
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82798
diff
changeset
|
18 |
command_offset: Symbol.Offset, |
| 72745 | 19 |
name: Document.Node.Name, |
|
72747
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
20 |
src_path: Path, |
| 75393 | 21 |
content: Option[(SHA1.Digest, Symbol.Text_Chunk)] |
22 |
) {
|
|
|
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72814
diff
changeset
|
23 |
def chunk_file: Symbol.Text_Chunk.File = |
|
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72814
diff
changeset
|
24 |
Symbol.Text_Chunk.File(name.node) |
|
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72814
diff
changeset
|
25 |
} |
| 72745 | 26 |
|
| 75393 | 27 |
object Blobs_Info {
|
| 76914 | 28 |
val empty: Blobs_Info = Blobs_Info(Nil) |
| 72814 | 29 |
|
| 76913 | 30 |
def make(blobs: List[(Blob, Document.Blobs.Item)]): Blobs_Info = |
| 76914 | 31 |
if (blobs.isEmpty) empty else Blobs_Info(for ((a, _) <- blobs) yield Exn.Res(a)) |
| 76913 | 32 |
|
| 72814 | 33 |
def errors(msgs: List[String]): Blobs_Info = |
| 72846 | 34 |
Blobs_Info(msgs.map(msg => Exn.Exn[Blob](ERROR(msg)))) |
| 72814 | 35 |
} |
36 |
||
| 72846 | 37 |
sealed case class Blobs_Info(blobs: List[Exn.Result[Blob]], index: Int = -1) |
| 72814 | 38 |
|
| 52849 | 39 |
|
40 |
||
| 38361 | 41 |
/** accumulated results from prover **/ |
42 |
||
| 50507 | 43 |
/* results */ |
44 |
||
| 75393 | 45 |
object Results {
|
| 72869 | 46 |
type Entry = (Long, XML.Elem) |
| 68101 | 47 |
val empty: Results = new Results(SortedMap.empty) |
| 73362 | 48 |
def make(args: IterableOnce[Results.Entry]): Results = |
49 |
args.iterator.foldLeft(empty)(_ + _) |
|
50 |
def merge(args: IterableOnce[Results]): Results = |
|
51 |
args.iterator.foldLeft(empty)(_ ++ _) |
|
|
83183
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
52 |
|
|
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
53 |
def warned(entry: Entry): Boolean = Protocol.is_warning_or_legacy(entry._2) |
|
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
54 |
def failed(entry: Entry): Boolean = Protocol.is_error(entry._2) |
| 50507 | 55 |
} |
56 |
||
| 75393 | 57 |
final class Results private(private val rep: SortedMap[Long, XML.Elem]) {
|
| 64802 | 58 |
def is_empty: Boolean = rep.isEmpty |
| 50507 | 59 |
def defined(serial: Long): Boolean = rep.isDefinedAt(serial) |
| 72869 | 60 |
def get(serial: Long): Option[XML.Elem] = rep.get(serial) |
|
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
61 |
def iterator: Iterator[Results.Entry] = rep.iterator |
|
50508
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
62 |
|
|
83183
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
63 |
def warned: Boolean = rep.exists(Results.warned) |
|
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
64 |
def failed: Boolean = rep.exists(Results.failed) |
| 83157 | 65 |
|
|
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
51494
diff
changeset
|
66 |
def + (entry: Results.Entry): Results = |
|
50508
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
67 |
if (defined(entry._1)) this |
|
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
68 |
else new Results(rep + entry) |
|
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
69 |
|
|
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
70 |
def ++ (other: Results): Results = |
|
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
71 |
if (this eq other) this |
|
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
72 |
else if (rep.isEmpty) other |
| 73359 | 73 |
else other.iterator.foldLeft(this)(_ + _) |
| 50540 | 74 |
|
| 51494 | 75 |
override def hashCode: Int = rep.hashCode |
76 |
override def equals(that: Any): Boolean = |
|
77 |
that match {
|
|
78 |
case other: Results => rep == other.rep |
|
79 |
case _ => false |
|
80 |
} |
|
|
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
81 |
override def toString: String = iterator.mkString("Results(", ", ", ")")
|
| 50507 | 82 |
} |
83 |
||
84 |
||
| 68101 | 85 |
/* exports */ |
86 |
||
| 75393 | 87 |
object Exports {
|
| 68101 | 88 |
type Entry = (Long, Export.Entry) |
89 |
val empty: Exports = new Exports(SortedMap.empty) |
|
| 73362 | 90 |
def merge(args: IterableOnce[Exports]): Exports = |
91 |
args.iterator.foldLeft(empty)(_ ++ _) |
|
| 68101 | 92 |
} |
93 |
||
| 75393 | 94 |
final class Exports private(private val rep: SortedMap[Long, Export.Entry]) {
|
| 69634 | 95 |
def is_empty: Boolean = rep.isEmpty |
| 68101 | 96 |
def iterator: Iterator[Exports.Entry] = rep.iterator |
97 |
||
98 |
def + (entry: Exports.Entry): Exports = |
|
99 |
if (rep.isDefinedAt(entry._1)) this |
|
100 |
else new Exports(rep + entry) |
|
101 |
||
102 |
def ++ (other: Exports): Exports = |
|
103 |
if (this eq other) this |
|
104 |
else if (rep.isEmpty) other |
|
| 73359 | 105 |
else other.iterator.foldLeft(this)(_ + _) |
| 68101 | 106 |
|
107 |
override def hashCode: Int = rep.hashCode |
|
108 |
override def equals(that: Any): Boolean = |
|
109 |
that match {
|
|
110 |
case other: Exports => rep == other.rep |
|
111 |
case _ => false |
|
112 |
} |
|
113 |
override def toString: String = iterator.mkString("Exports(", ", ", ")")
|
|
114 |
} |
|
115 |
||
116 |
||
117 |
/* markups */ |
|
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
118 |
|
| 75393 | 119 |
object Markup_Index {
|
| 56746 | 120 |
val markup: Markup_Index = Markup_Index(false, Symbol.Text_Chunk.Default) |
|
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72814
diff
changeset
|
121 |
def blob(blob: Blob): Markup_Index = Markup_Index(false, blob.chunk_file) |
|
76912
ca872f20cf5b
clarified session sources: theory and blobs are read from database, instead of physical file-system;
wenzelm
parents:
76908
diff
changeset
|
122 |
def make(blobs: List[Blob]): List[Markup_Index] = markup :: blobs.map(blob) |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
123 |
} |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
124 |
|
| 56746 | 125 |
sealed case class Markup_Index(status: Boolean, chunk_name: Symbol.Text_Chunk.Name) |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
126 |
|
| 75393 | 127 |
object Markups {
|
|
72848
d5d0e36eda16
read theory with PIDE markup from session database;
wenzelm
parents:
72846
diff
changeset
|
128 |
type Entry = (Markup_Index, Markup_Tree) |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
129 |
val empty: Markups = new Markups(Map.empty) |
| 65335 | 130 |
def init(markup: Markup_Tree): Markups = new Markups(Map(Markup_Index.markup -> markup)) |
| 73362 | 131 |
def make(args: IterableOnce[Entry]): Markups = |
132 |
args.iterator.foldLeft(empty)(_ + _) |
|
133 |
def merge(args: IterableOnce[Markups]): Markups = |
|
134 |
args.iterator.foldLeft(empty)(_ ++ _) |
|
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
135 |
} |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
136 |
|
| 75393 | 137 |
final class Markups private(private val rep: Map[Markup_Index, Markup_Tree]) {
|
| 56489 | 138 |
def is_empty: Boolean = rep.isEmpty |
139 |
||
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
140 |
def apply(index: Markup_Index): Markup_Tree = |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
141 |
rep.getOrElse(index, Markup_Tree.empty) |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
142 |
|
| 82798 | 143 |
def add(markup: Text.Markup): Markups = add(Markup_Index.markup, markup) |
144 |
||
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
145 |
def add(index: Markup_Index, markup: Text.Markup): Markups = |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
146 |
new Markups(rep + (index -> (this(index) + markup))) |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
147 |
|
| 75393 | 148 |
def + (entry: Markups.Entry): Markups = {
|
| 65335 | 149 |
val (index, tree) = entry |
150 |
new Markups(rep + (index -> (this(index).merge(tree, Text.Range.full, Markup.Elements.full)))) |
|
151 |
} |
|
152 |
||
153 |
def ++ (other: Markups): Markups = |
|
154 |
if (this eq other) this |
|
155 |
else if (rep.isEmpty) other |
|
| 73359 | 156 |
else other.rep.iterator.foldLeft(this)(_ + _) |
| 65335 | 157 |
|
| 56475 | 158 |
def redirection_iterator: Iterator[Document_ID.Generic] = |
| 78592 | 159 |
for (case Markup_Index(_, Symbol.Text_Chunk.Id(id)) <- rep.keysIterator) |
| 56475 | 160 |
yield id |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
161 |
|
| 75393 | 162 |
def redirect(other_id: Document_ID.Generic): Markups = {
|
| 56489 | 163 |
val rep1 = |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
164 |
(for {
|
| 78592 | 165 |
case (Markup_Index(status, Symbol.Text_Chunk.Id(id)), markup) <- rep.iterator |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
166 |
if other_id == id |
| 56746 | 167 |
} yield (Markup_Index(status, Symbol.Text_Chunk.Default), markup)).toMap |
| 56489 | 168 |
if (rep1.isEmpty) Markups.empty else new Markups(rep1) |
169 |
} |
|
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
170 |
|
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
171 |
override def hashCode: Int = rep.hashCode |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
172 |
override def equals(that: Any): Boolean = |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
173 |
that match {
|
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
174 |
case other: Markups => rep == other.rep |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
175 |
case _ => false |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
176 |
} |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
177 |
override def toString: String = rep.iterator.mkString("Markups(", ", ", ")")
|
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
178 |
} |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
179 |
|
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
180 |
|
| 50507 | 181 |
/* state */ |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
182 |
|
| 75393 | 183 |
object State {
|
| 72869 | 184 |
def get_result(states: List[State], serial: Long): Option[XML.Elem] = |
|
67824
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67446
diff
changeset
|
185 |
states.find(st => st.results.defined(serial)).map(st => st.results.get(serial).get) |
|
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67446
diff
changeset
|
186 |
|
|
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67446
diff
changeset
|
187 |
def get_result_proper(states: List[State], props: Properties.T): Option[Results.Entry] = |
|
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67446
diff
changeset
|
188 |
for {
|
|
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67446
diff
changeset
|
189 |
serial <- Markup.Serial.unapply(props) |
| 72869 | 190 |
elem <- get_result(states, serial) |
191 |
if elem.body.nonEmpty |
|
192 |
} yield serial -> elem |
|
|
67824
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67446
diff
changeset
|
193 |
|
| 65335 | 194 |
def merge_results(states: List[State]): Results = |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
195 |
Results.merge(states.map(_.results)) |
|
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
196 |
|
| 68101 | 197 |
def merge_exports(states: List[State]): Exports = |
198 |
Exports.merge(states.map(_.exports)) |
|
199 |
||
| 65335 | 200 |
def merge_markups(states: List[State]): Markups = |
201 |
Markups.merge(states.map(_.markups)) |
|
202 |
||
|
56301
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56299
diff
changeset
|
203 |
def merge_markup(states: List[State], index: Markup_Index, |
| 56743 | 204 |
range: Text.Range, elements: Markup.Elements): Markup_Tree = |
|
56301
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56299
diff
changeset
|
205 |
Markup_Tree.merge(states.map(_.markup(index)), range, elements) |
| 65335 | 206 |
|
207 |
def merge(command: Command, states: List[State]): State = |
|
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
208 |
State(command, |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
209 |
results = merge_results(states), |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
210 |
exports = merge_exports(states), |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
211 |
markups = merge_markups(states)) |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
212 |
|
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
213 |
def apply( |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
214 |
command: Command, |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
215 |
results: Results = Results.empty, |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
216 |
exports: Exports = Exports.empty, |
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
217 |
markups: Markups = Markups.empty, |
|
83183
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
218 |
): State = {
|
|
83216
62f665014a4f
more concise storage of Command.State: omit pointless status: List[Markup];
wenzelm
parents:
83210
diff
changeset
|
219 |
new State(command, results, exports, markups, |
|
83503
7b1b7ac616c0
more robust representation of start time as Date;
wenzelm
parents:
83297
diff
changeset
|
220 |
Document_Status.Command_Status.make(Date.now(), |
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
221 |
warned = results.warned, |
|
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
222 |
failed = results.failed)) |
|
83183
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
223 |
} |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
224 |
} |
|
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
225 |
|
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
226 |
final class State private[Command]( |
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
227 |
val command: Command, |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
228 |
val results: Results, |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
229 |
val exports: Exports, |
|
83183
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
230 |
val markups: Markups, |
|
6e03fb945baf
more scalable Command.State.document_status: prefer incremental update;
wenzelm
parents:
83182
diff
changeset
|
231 |
val document_status: Document_Status.Command_Status |
| 75393 | 232 |
) {
|
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
233 |
override def toString: String = "Command.State(" + command + ")"
|
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
234 |
override def hashCode(): Int = ??? |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
235 |
override def equals(obj: Any): Boolean = ??? |
|
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
236 |
|
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
237 |
def initialized: Boolean = document_status.initialized |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
238 |
def consolidating: Boolean = document_status.consolidating |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
239 |
def consolidated: Boolean = document_status.consolidated |
|
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
240 |
def maybe_consolidated: Boolean = document_status.maybe_consolidated |
|
83210
9cc5d77d505c
more detailed Command_Timings: count actual commands from theory body individually;
wenzelm
parents:
83186
diff
changeset
|
241 |
def timings: Document_Status.Command_Timings = document_status.timings |
|
83158
7e94f31b6d6c
clarified signature: more explicit type Theory_Status;
wenzelm
parents:
83157
diff
changeset
|
242 |
|
| 55650 | 243 |
def markup(index: Markup_Index): Markup_Tree = markups(index) |
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
244 |
|
| 75393 | 245 |
def redirect(other_command: Command): Option[State] = {
|
| 56489 | 246 |
val markups1 = markups.redirect(other_command.id) |
247 |
if (markups1.is_empty) None |
|
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
248 |
else Some(State(other_command, markups = markups1)) |
| 56489 | 249 |
} |
| 49614 | 250 |
|
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
251 |
def exit(id: Document_ID.Generic): Command = |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
252 |
new Command(id, command.node_name, command.blobs_info, command.span, command.source, |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
253 |
results, exports, markups, document_status) |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
254 |
|
|
83503
7b1b7ac616c0
more robust representation of start time as Date;
wenzelm
parents:
83297
diff
changeset
|
255 |
private def add_status(now: Date, st: Markup): State = |
| 83288 | 256 |
new State(command, results, exports, markups, |
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
257 |
document_status.update(now, markups = List(st))) |
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
258 |
|
|
83503
7b1b7ac616c0
more robust representation of start time as Date;
wenzelm
parents:
83297
diff
changeset
|
259 |
private def add_result(now: Date, entry: Results.Entry): State = |
| 83288 | 260 |
new State(command, results + entry, exports, markups, |
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
261 |
document_status.update(now, |
| 83184 | 262 |
warned = Results.warned(entry), |
| 83288 | 263 |
failed = Results.failed(entry))) |
| 67826 | 264 |
|
| 68114 | 265 |
def add_export(entry: Exports.Entry): Option[State] = |
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
266 |
if (command.node_name.theory == entry._2.theory_name) {
|
|
83216
62f665014a4f
more concise storage of Command.State: omit pointless status: List[Markup];
wenzelm
parents:
83210
diff
changeset
|
267 |
Some(new State(command, results, exports + entry, markups, document_status)) |
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
268 |
} |
| 68114 | 269 |
else None |
| 68101 | 270 |
|
| 56746 | 271 |
private def add_markup( |
| 82740 | 272 |
m: Text.Markup, |
273 |
chunk_name: Symbol.Text_Chunk.Name = Symbol.Text_Chunk.Default, |
|
274 |
status: Boolean = false |
|
| 75393 | 275 |
): State = {
|
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
276 |
val markups1 = |
| 68758 | 277 |
if (status || Document_Status.Command_Status.liberal_elements(m.info.name)) |
|
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
278 |
markups.add(Markup_Index(true, chunk_name), m) |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
279 |
else markups |
|
83182
2472024d9a1c
clarified signature: more abstract type Command.State, without hasCode/equals to avoid semantic confusion;
wenzelm
parents:
83171
diff
changeset
|
280 |
val markups2 = markups1.add(Markup_Index(false, chunk_name), m) |
|
83216
62f665014a4f
more concise storage of Command.State: omit pointless status: List[Markup];
wenzelm
parents:
83210
diff
changeset
|
281 |
new State(command, results, exports, markups2, document_status) |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
282 |
} |
| 38361 | 283 |
|
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
284 |
def accumulate( |
|
83503
7b1b7ac616c0
more robust representation of start time as Date;
wenzelm
parents:
83297
diff
changeset
|
285 |
now: Date, |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
286 |
self_id: Document_ID.Generic => Boolean, |
| 72780 | 287 |
other_id: (Document.Node.Name, Document_ID.Generic) => |
288 |
Option[(Symbol.Text_Chunk.Id, Symbol.Text_Chunk)], |
|
| 67825 | 289 |
message: XML.Elem, |
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
72962
diff
changeset
|
290 |
cache: XML.Cache): State = |
| 38361 | 291 |
message match {
|
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
292 |
case XML.Elem(markup@Markup(Markup.Command_Timing.name, _), _) => |
|
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
293 |
add_status(now, markup) |
|
83217
77dcdddc9b20
clarified internal protocol: accept is_theory, reject add_markup;
wenzelm
parents:
83216
diff
changeset
|
294 |
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
295 |
case XML.Elem(Markup(Markup.STATUS, _), msgs) => |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
296 |
if (command.span.is_theory) this |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
297 |
else {
|
| 73359 | 298 |
msgs.foldLeft(this) {
|
299 |
case (state, msg) => |
|
300 |
msg match {
|
|
301 |
case elem @ XML.Elem(markup, Nil) => |
|
302 |
state. |
|
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
303 |
add_status(now, markup). |
| 82740 | 304 |
add_markup(Text.Info(command.core_range, elem), status = true) |
| 73359 | 305 |
case _ => |
306 |
Output.warning("Ignored status message: " + msg)
|
|
307 |
state |
|
308 |
} |
|
309 |
} |
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
310 |
} |
|
38581
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38579
diff
changeset
|
311 |
|
|
72709
cb9d5af781b4
more complete report positions, notably for command 'back' (amending eca176f773e0);
wenzelm
parents:
72708
diff
changeset
|
312 |
case XML.Elem(Markup(Markup.REPORT, atts0), msgs) => |
| 73359 | 313 |
msgs.foldLeft(this) {
|
314 |
case (state, msg) => |
|
|
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
56746
diff
changeset
|
315 |
def bad(): Unit = Output.warning("Ignored report message: " + msg)
|
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
316 |
|
|
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
317 |
msg match {
|
|
72826
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
318 |
case XML.Elem(Markup(name, atts), args) => |
|
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
319 |
command.reported_position(atts) orElse command.reported_position(atts0) match {
|
|
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
320 |
case Some((id, chunk_name, target_range)) => |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
321 |
val target = |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
322 |
if (self_id(id) && command.chunks.isDefinedAt(chunk_name)) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
323 |
Some((chunk_name, command.chunks(chunk_name))) |
| 72780 | 324 |
else if (chunk_name == Symbol.Text_Chunk.Default) |
325 |
other_id(command.node_name, id) |
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
326 |
else None |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
327 |
|
|
72826
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
328 |
(target, target_range) match {
|
|
72831
ffae996e9c08
silently ignore markup that starts out as singularity, e.g. <language/> from empty ML file;
wenzelm
parents:
72827
diff
changeset
|
329 |
case (Some((target_name, target_chunk)), Some(symbol_range)) |
|
ffae996e9c08
silently ignore markup that starts out as singularity, e.g. <language/> from empty ML file;
wenzelm
parents:
72827
diff
changeset
|
330 |
if !symbol_range.is_singularity => |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
331 |
target_chunk.incorporate(symbol_range) match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
332 |
case Some(range) => |
| 72708 | 333 |
val props = atts.filterNot(Markup.position_property) |
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
72962
diff
changeset
|
334 |
val elem = cache.elem(XML.Elem(Markup(name, props), args)) |
| 82740 | 335 |
state.add_markup(Text.Info(range, elem), chunk_name = target_name) |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
336 |
case None => bad(); state |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
337 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
338 |
case _ => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
339 |
// silently ignore excessive reports |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
340 |
state |
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
341 |
} |
|
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
342 |
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
343 |
case _ => bad(); state |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
344 |
} |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56469
diff
changeset
|
345 |
case _ => bad(); state |
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
346 |
} |
| 73359 | 347 |
} |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
348 |
|
|
52930
5fab62ae3532
retain original messages properties, e.g. for retrieval via Command.Results;
wenzelm
parents:
52849
diff
changeset
|
349 |
case XML.Elem(Markup(name, props), body) => |
|
5fab62ae3532
retain original messages properties, e.g. for retrieval via Command.Results;
wenzelm
parents:
52849
diff
changeset
|
350 |
props match {
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
351 |
case Markup.Serial(i) => |
| 81430 | 352 |
val markup_message = cache.elem(Protocol.make_message(body, name, props = props)) |
353 |
val message_markup = cache.elem(XML.elem(Markup(name, Markup.Serial(i)))) |
|
|
50163
c62ce309dc26
more abstract Sendback operations, with explicit id/exec_id properties;
wenzelm
parents:
50158
diff
changeset
|
354 |
|
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
355 |
var st = add_result(now, i -> markup_message) |
|
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
356 |
if (Protocol.is_inlined(message)) {
|
|
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
357 |
for {
|
| 56469 | 358 |
(chunk_name, chunk) <- command.chunks.iterator |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
359 |
range <- command.message_positions(self_id, chunk_name, chunk, message) |
| 82740 | 360 |
} st = st.add_markup(Text.Info(range, message_markup), chunk_name = chunk_name) |
|
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
361 |
} |
|
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
362 |
st |
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
363 |
|
| 52536 | 364 |
case _ => |
|
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
56746
diff
changeset
|
365 |
Output.warning("Ignored message without serial number: " + message)
|
| 52536 | 366 |
this |
| 38872 | 367 |
} |
| 68101 | 368 |
} |
| 38361 | 369 |
} |
| 38367 | 370 |
|
371 |
||
|
55431
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
372 |
|
|
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
373 |
/** static content **/ |
|
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
374 |
|
| 45644 | 375 |
/* make commands */ |
376 |
||
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
377 |
def apply( |
|
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
378 |
id: Document_ID.Command, |
|
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
379 |
node_name: Document.Node.Name, |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
380 |
blobs_info: Blobs_Info, |
| 75393 | 381 |
span: Command_Span.Span |
382 |
): Command = {
|
|
|
57901
e1abca2527da
more explicit type Span in Scala, according to ML version;
wenzelm
parents:
57842
diff
changeset
|
383 |
val (source, span1) = span.compact_source |
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
384 |
new Command(id, node_name, blobs_info, span1, source, |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
385 |
Results.empty, Exports.empty, Markups.empty, Document_Status.Command_Status.empty) |
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
386 |
} |
| 49414 | 387 |
|
|
57901
e1abca2527da
more explicit type Span in Scala, according to ML version;
wenzelm
parents:
57842
diff
changeset
|
388 |
val empty: Command = |
| 76914 | 389 |
Command(Document_ID.none, Document.Node.Name.empty, Blobs_Info.empty, Command_Span.empty) |
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
390 |
|
|
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
391 |
def unparsed( |
|
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
392 |
source: String, |
| 83226 | 393 |
theory_commands: Option[Int] = None, |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
394 |
id: Document_ID.Command = Document_ID.none, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
395 |
node_name: Document.Node.Name = Document.Node.Name.empty, |
| 76914 | 396 |
blobs_info: Blobs_Info = Blobs_Info.empty, |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
397 |
results: Results = Results.empty, |
| 75393 | 398 |
markups: Markups = Markups.empty |
399 |
): Command = {
|
|
| 83226 | 400 |
val span = Command_Span.unparsed(source, theory_commands = theory_commands) |
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
401 |
new Command(id, node_name, blobs_info, span, source, results, |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
402 |
Exports.empty, markups, Document_Status.Command_Status.empty) |
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
403 |
} |
| 49414 | 404 |
|
| 44384 | 405 |
|
| 72814 | 406 |
/* edits and perspective */ |
407 |
||
408 |
type Edit = (Option[Command], Option[Command]) |
|
| 44384 | 409 |
|
| 75393 | 410 |
object Perspective {
|
| 44474 | 411 |
val empty: Perspective = Perspective(Nil) |
412 |
} |
|
|
44385
e7fdb008aa7d
propagate editor perspective through document model;
wenzelm
parents:
44384
diff
changeset
|
413 |
|
| 75393 | 414 |
sealed case class Perspective( |
415 |
commands: List[Command] // visible commands in canonical order |
|
416 |
) {
|
|
|
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
56782
diff
changeset
|
417 |
def is_empty: Boolean = commands.isEmpty |
|
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
56782
diff
changeset
|
418 |
|
| 75393 | 419 |
def same(that: Perspective): Boolean = {
|
| 44474 | 420 |
val cmds1 = this.commands |
421 |
val cmds2 = that.commands |
|
|
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73115
diff
changeset
|
422 |
require(!cmds1.exists(_.is_undefined), "cmds1 not defined") |
|
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73115
diff
changeset
|
423 |
require(!cmds2.exists(_.is_undefined), "cmds2 not defined") |
| 44474 | 424 |
cmds1.length == cmds2.length && |
425 |
(cmds1.iterator zip cmds2.iterator).forall({ case (c1, c2) => c1.id == c2.id })
|
|
426 |
} |
|
|
44385
e7fdb008aa7d
propagate editor perspective through document model;
wenzelm
parents:
44384
diff
changeset
|
427 |
} |
|
59689
7968c57ea240
simplified Command.resolve_files in ML, using blobs_index from Scala;
wenzelm
parents:
59684
diff
changeset
|
428 |
|
|
7968c57ea240
simplified Command.resolve_files in ML, using blobs_index from Scala;
wenzelm
parents:
59684
diff
changeset
|
429 |
|
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
430 |
/* blobs: inlined errors and auxiliary files */ |
|
59689
7968c57ea240
simplified Command.resolve_files in ML, using blobs_index from Scala;
wenzelm
parents:
59684
diff
changeset
|
431 |
|
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
432 |
def blobs_info( |
| 59699 | 433 |
resources: Resources, |
|
63584
68751fe1c036
tuned signature -- prover-independence is presently theoretical;
wenzelm
parents:
62969
diff
changeset
|
434 |
syntax: Outer_Syntax, |
|
76904
e27d097d7d15
tuned signature: avoid confusion with Document.Node.Blob and Command.Blob;
wenzelm
parents:
76879
diff
changeset
|
435 |
get_blob: Document.Node.Name => Option[Document.Blobs.Item], |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
436 |
can_import: Document.Node.Name => Boolean, |
| 59699 | 437 |
node_name: Document.Node.Name, |
| 75393 | 438 |
span: Command_Span.Span |
439 |
): Blobs_Info = {
|
|
| 59735 | 440 |
span.name match {
|
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
441 |
// inlined errors |
| 59735 | 442 |
case Thy_Header.THEORY => |
| 72946 | 443 |
val reader = span.content_reader |
444 |
val header = resources.check_thy(node_name, span.content_reader) |
|
|
72748
04d5f6d769a7
more flexible syntax for theory load commands via Isabelle/Scala;
wenzelm
parents:
72747
diff
changeset
|
445 |
val imports_pos = header.imports_pos |
| 66768 | 446 |
val raw_imports = |
447 |
try {
|
|
| 72778 | 448 |
val read_imports = Thy_Header.read(node_name, reader).imports.map(_._1) |
|
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
69891
diff
changeset
|
449 |
if (imports_pos.length == read_imports.length) read_imports else error("")
|
| 66768 | 450 |
} |
| 72778 | 451 |
catch { case _: Throwable => List.fill(header.imports.length)("") }
|
| 66768 | 452 |
|
| 72765 | 453 |
val errors = |
|
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
69891
diff
changeset
|
454 |
for { ((import_name, pos), s) <- imports_pos zip raw_imports if !can_import(import_name) }
|
| 66768 | 455 |
yield {
|
456 |
val completion = |
|
| 76828 | 457 |
if (Url.is_base_name(s)) resources.complete_import_name(node_name, s) else Nil |
| 72814 | 458 |
"Bad theory import " + |
459 |
Markup.Path(import_name.node).markup(quote(import_name.toString)) + |
|
460 |
Position.here(pos) + Completion.report_theories(pos, completion) |
|
|
59708
aed304412e43
more markup, which helps to create missing imports;
wenzelm
parents:
59706
diff
changeset
|
461 |
} |
| 72814 | 462 |
Blobs_Info.errors(errors) |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
463 |
|
|
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
464 |
// auxiliary files |
|
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
465 |
case _ => |
| 72757 | 466 |
val loaded_files = span.loaded_files(syntax) |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
467 |
val blobs = |
| 72757 | 468 |
loaded_files.files.map(file => |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
469 |
(Exn.capture {
|
|
72747
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
470 |
val src_path = Path.explode(file) |
| 76858 | 471 |
val name = Document.Node.Name(resources.append_path(node_name.master_dir, src_path)) |
| 72745 | 472 |
val content = get_blob(name).map(blob => (blob.bytes.sha1_digest, blob.chunk)) |
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82798
diff
changeset
|
473 |
Blob(0, name, src_path, content) |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
474 |
}).user_error) |
| 72846 | 475 |
Blobs_Info(blobs, index = loaded_files.index) |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
476 |
} |
|
59689
7968c57ea240
simplified Command.resolve_files in ML, using blobs_index from Scala;
wenzelm
parents:
59684
diff
changeset
|
477 |
} |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
478 |
} |
|
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
479 |
|
| 38361 | 480 |
|
| 46712 | 481 |
final class Command private( |
| 75393 | 482 |
val id: Document_ID.Command, |
483 |
val node_name: Document.Node.Name, |
|
484 |
val blobs_info: Command.Blobs_Info, |
|
485 |
val span: Command_Span.Span, |
|
486 |
val source: String, |
|
487 |
val init_results: Command.Results, |
|
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
488 |
val init_exports: Command.Exports, |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
489 |
val init_markups: Command.Markups, |
|
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
490 |
val init_document_status: Document_Status.Command_Status |
| 75393 | 491 |
) {
|
| 73363 | 492 |
override def toString: String = id.toString + "/" + span.kind.toString |
| 34495 | 493 |
|
| 57910 | 494 |
|
495 |
/* classification */ |
|
496 |
||
|
57905
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57904
diff
changeset
|
497 |
def is_proper: Boolean = span.kind.isInstanceOf[Command_Span.Command_Span] |
|
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57904
diff
changeset
|
498 |
def is_ignored: Boolean = span.kind == Command_Span.Ignored_Span |
| 57904 | 499 |
|
500 |
def is_undefined: Boolean = id == Document_ID.none |
|
|
81432
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
501 |
lazy val is_unparsed: Boolean = span.content.exists(_.is_unparsed) |
|
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
502 |
lazy val is_unfinished: Boolean = span.content.exists(_.is_unfinished) |
| 57904 | 503 |
|
| 34859 | 504 |
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
505 |
/* blobs */ |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
506 |
|
| 72814 | 507 |
def blobs: List[Exn.Result[Command.Blob]] = blobs_info.blobs |
508 |
def blobs_index: Int = blobs_info.index |
|
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
509 |
|
| 78674 | 510 |
def blobs_ok: Boolean = blobs.forall(Exn.is_res) |
| 65335 | 511 |
|
|
54530
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54524
diff
changeset
|
512 |
def blobs_names: List[Document.Node.Name] = |
| 78592 | 513 |
for (case Exn.Res(blob) <- blobs) yield blob.name |
|
54530
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54524
diff
changeset
|
514 |
|
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82798
diff
changeset
|
515 |
def blobs_files: List[(Symbol.Offset, Document.Node.Name)] = |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82798
diff
changeset
|
516 |
for (case Exn.Res(blob) <- blobs) yield (blob.command_offset, blob.name) |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82798
diff
changeset
|
517 |
|
|
60916
a6e2a667b0a8
resolve undefined blobs by default, e.g. relevant for ML debugger to avoid reset of breakpoints after reload;
wenzelm
parents:
60215
diff
changeset
|
518 |
def blobs_undefined: List[Document.Node.Name] = |
| 78592 | 519 |
for (case Exn.Res(blob) <- blobs if blob.content.isEmpty) yield blob.name |
|
60916
a6e2a667b0a8
resolve undefined blobs by default, e.g. relevant for ML debugger to avoid reset of breakpoints after reload;
wenzelm
parents:
60215
diff
changeset
|
520 |
|
|
57842
8e4ae2db1849
more direct access to persistent blobs (see also 8953d4cc060a), avoiding fragile digest lookup from later version (which might have removed unused blobs already);
wenzelm
parents:
57615
diff
changeset
|
521 |
def blobs_defined: List[(Document.Node.Name, SHA1.Digest)] = |
| 78592 | 522 |
for (case Exn.Res(blob) <- blobs; (digest, _) <- blob.content) yield (blob.name, digest) |
|
57842
8e4ae2db1849
more direct access to persistent blobs (see also 8953d4cc060a), avoiding fragile digest lookup from later version (which might have removed unused blobs already);
wenzelm
parents:
57615
diff
changeset
|
523 |
|
|
8e4ae2db1849
more direct access to persistent blobs (see also 8953d4cc060a), avoiding fragile digest lookup from later version (which might have removed unused blobs already);
wenzelm
parents:
57615
diff
changeset
|
524 |
def blobs_changed(doc_blobs: Document.Blobs): Boolean = |
| 72745 | 525 |
blobs.exists({ case Exn.Res(blob) => doc_blobs.changed(blob.name) case _ => false })
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
526 |
|
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
527 |
|
|
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
528 |
/* source chunks */ |
|
55431
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
529 |
|
|
81432
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
530 |
lazy val chunk: Symbol.Text_Chunk = Symbol.Text_Chunk(source) |
| 56473 | 531 |
|
|
81432
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
532 |
lazy val chunks: Map[Symbol.Text_Chunk.Name, Symbol.Text_Chunk] = |
| 56746 | 533 |
((Symbol.Text_Chunk.Default -> chunk) :: |
| 78592 | 534 |
(for (case Exn.Res(blob) <- blobs; (_, file) <- blob.content) |
|
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72814
diff
changeset
|
535 |
yield blob.chunk_file -> file)).toMap |
| 56473 | 536 |
|
| 46813 | 537 |
def length: Int = source.length |
| 56473 | 538 |
def range: Text.Range = chunk.range |
| 46813 | 539 |
|
|
81432
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
540 |
lazy val core_range: Text.Range = |
|
57901
e1abca2527da
more explicit type Span in Scala, according to ML version;
wenzelm
parents:
57842
diff
changeset
|
541 |
Text.Range(0, |
| 76234 | 542 |
span.content.reverseIterator.takeWhile(_.is_ignored).foldLeft(length)(_ - _.source.length)) |
| 46813 | 543 |
|
| 65522 | 544 |
def source(range: Text.Range): String = range.substring(source) |
|
38572
0fe2c01ef7da
Command.State: accumulate markup reports uniformly;
wenzelm
parents:
38564
diff
changeset
|
545 |
|
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
546 |
|
| 72946 | 547 |
/* theory parents */ |
548 |
||
549 |
def theory_parents(resources: Resources): List[Document.Node.Name] = |
|
550 |
if (span.name == Thy_Header.THEORY) {
|
|
551 |
try {
|
|
552 |
val header = Thy_Header.read(node_name, span.content_reader) |
|
553 |
for ((s, _) <- header.imports) |
|
554 |
yield {
|
|
555 |
try { resources.import_name(node_name, s) }
|
|
556 |
catch { case ERROR(_) => Document.Node.Name.empty }
|
|
557 |
} |
|
558 |
} |
|
559 |
catch { case ERROR(_) => Nil }
|
|
560 |
} |
|
561 |
else Nil |
|
562 |
||
563 |
||
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
564 |
/* reported positions */ |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
565 |
|
| 75393 | 566 |
def reported_position( |
567 |
pos: Position.T |
|
568 |
) : Option[(Document_ID.Generic, Symbol.Text_Chunk.Name, Option[Symbol.Range])] = {
|
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
569 |
pos match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
570 |
case Position.Id(id) => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
571 |
val chunk_name = |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
572 |
pos match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
573 |
case Position.File(name) if name != node_name.node => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
574 |
Symbol.Text_Chunk.File(name) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
575 |
case _ => Symbol.Text_Chunk.Default |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
576 |
} |
|
72826
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
577 |
Some((id, chunk_name, Position.Range.unapply(pos))) |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
578 |
case _ => None |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
579 |
} |
|
72826
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
580 |
} |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
581 |
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
582 |
def message_positions( |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
583 |
self_id: Document_ID.Generic => Boolean, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
584 |
chunk_name: Symbol.Text_Chunk.Name, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
585 |
chunk: Symbol.Text_Chunk, |
| 75393 | 586 |
message: XML.Elem |
587 |
): Set[Text.Range] = {
|
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
588 |
def elem(props: Properties.T, set: Set[Text.Range]): Set[Text.Range] = |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
589 |
reported_position(props) match {
|
|
72826
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
590 |
case Some((id, name, reported_range)) if self_id(id) && name == chunk_name => |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
591 |
val opt_range = |
|
72826
fa5d8f486380
proper treatment of singleton Position.Offset within blob (amending cb9d5af781b4);
wenzelm
parents:
72824
diff
changeset
|
592 |
reported_range orElse {
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
593 |
if (name == Symbol.Text_Chunk.Default) |
|
73115
a8e5d7c9a834
discontinued odd absolute position (amending 85bcdd05c6d0, 1975f397eabb): it violates translation invariance of commands and may lead to redundant re-checking of PIDE document;
wenzelm
parents:
73031
diff
changeset
|
594 |
Position.Range.unapply(span.position) |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
595 |
else None |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
596 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
597 |
opt_range match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
598 |
case Some(symbol_range) => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
599 |
chunk.incorporate(symbol_range) match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
600 |
case Some(range) => set + range |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
601 |
case _ => set |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
602 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
603 |
case None => set |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
604 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
605 |
case _ => set |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
606 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
607 |
def tree(set: Set[Text.Range], t: XML.Tree): Set[Text.Range] = |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
608 |
t match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
609 |
case XML.Wrapped_Elem(Markup(name, props), _, body) => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
610 |
body.foldLeft(if (Rendering.position_elements(name)) elem(props, set) else set)(tree) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
611 |
case XML.Elem(Markup(name, props), body) => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
612 |
body.foldLeft(if (Rendering.position_elements(name)) elem(props, set) else set)(tree) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
613 |
case XML.Text(_) => set |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
614 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
615 |
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
616 |
val set = tree(Set.empty, message) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
617 |
if (set.isEmpty) elem(message.markup.properties, set) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
618 |
else set |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
619 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
620 |
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
70780
diff
changeset
|
621 |
|
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
622 |
/* accumulated results */ |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
623 |
|
|
81432
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
624 |
lazy val init_state: Command.State = |
|
83218
7409cb179fba
more thorough Command.State.exit vs. Command.init_state: avoid loss of information in Document.State.end_theory (notably Command_Timings);
wenzelm
parents:
83217
diff
changeset
|
625 |
new Command.State(this, init_results, init_exports, init_markups, |
|
83503
7b1b7ac616c0
more robust representation of start time as Date;
wenzelm
parents:
83297
diff
changeset
|
626 |
init_document_status.update(Date.now(), |
|
83297
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
627 |
warned = init_results.warned, |
|
00bb83e60336
clarified command_timing protocol: support for still running commands, with timing approximated in Isabelle/Scala;
wenzelm
parents:
83294
diff
changeset
|
628 |
failed = init_results.failed)) |
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52524
diff
changeset
|
629 |
|
|
81432
85fc3b482924
clarified persistent values: Command.Results does not suitable for caching, because it contains all other messages;
wenzelm
parents:
81431
diff
changeset
|
630 |
lazy val empty_state: Command.State = Command.State(this) |
|
34676
9e725d34df7b
Command and Command_State handle results from prover as Accumulator
immler@in.tum.de
parents:
34675
diff
changeset
|
631 |
} |