author | wenzelm |
Fri, 01 Apr 2022 17:06:10 +0200 | |
changeset 75393 | 87ebf5a50283 |
parent 73361 | ef8c9b3d5355 |
child 75394 | 42267c650205 |
permissions | -rw-r--r-- |
36676 | 1 |
/* Title: Pure/PIDE/document.scala |
2 |
Author: Makarius |
|
3 |
||
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
4 |
Document as collection of named nodes, each consisting of an editable |
38418
9a7af64d71bb
more explicit / functional ML version of document model;
wenzelm
parents:
38417
diff
changeset
|
5 |
list of commands, associated with asynchronous execution process. |
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:
34868
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 |
|
34760 | 10 |
|
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
11 |
import scala.collection.mutable |
37073 | 12 |
|
13 |
||
75393 | 14 |
object Document { |
38424 | 15 |
/** document structure **/ |
16 |
||
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
17 |
/* overlays -- print functions with arguments */ |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
18 |
|
75393 | 19 |
object Overlays { |
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
20 |
val empty = new Overlays(Map.empty) |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
21 |
} |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
22 |
|
75393 | 23 |
final class Overlays private(rep: Map[Node.Name, Node.Overlays]) { |
64799 | 24 |
def apply(name: Node.Name): Node.Overlays = |
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
25 |
rep.getOrElse(name, Node.Overlays.empty) |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
26 |
|
75393 | 27 |
private def update(name: Node.Name, f: Node.Overlays => Node.Overlays): Overlays = { |
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
28 |
val node_overlays = f(apply(name)) |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
29 |
new Overlays(if (node_overlays.is_empty) rep - name else rep + (name -> node_overlays)) |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
30 |
} |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
31 |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
32 |
def insert(command: Command, fn: String, args: List[String]): Overlays = |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
33 |
update(command.node_name, _.insert(command, fn, args)) |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
34 |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
35 |
def remove(command: Command, fn: String, args: List[String]): Overlays = |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
36 |
update(command.node_name, _.remove(command, fn, args)) |
55800 | 37 |
|
38 |
override def toString: String = rep.mkString("Overlays(", ",", ")") |
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
39 |
} |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
40 |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
41 |
|
55783 | 42 |
/* document blobs: auxiliary files */ |
43 |
||
75393 | 44 |
sealed case class Blob(bytes: Bytes, source: String, chunk: Symbol.Text_Chunk, changed: Boolean) { |
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56314
diff
changeset
|
45 |
def unchanged: Blob = copy(changed = false) |
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56314
diff
changeset
|
46 |
} |
55783 | 47 |
|
75393 | 48 |
object Blobs { |
56336 | 49 |
def apply(blobs: Map[Node.Name, Blob]): Blobs = new Blobs(blobs) |
55783 | 50 |
val empty: Blobs = apply(Map.empty) |
51 |
} |
|
52 |
||
75393 | 53 |
final class Blobs private(blobs: Map[Node.Name, Blob]) { |
56336 | 54 |
def get(name: Node.Name): Option[Blob] = blobs.get(name) |
55783 | 55 |
|
56 |
def changed(name: Node.Name): Boolean = |
|
57 |
get(name) match { |
|
58 |
case Some(blob) => blob.changed |
|
59 |
case None => false |
|
60 |
} |
|
61 |
||
55800 | 62 |
override def toString: String = blobs.mkString("Blobs(", ",", ")") |
55783 | 63 |
} |
64 |
||
65 |
||
66 |
/* document nodes: theories and auxiliary files */ |
|
38424 | 67 |
|
44615 | 68 |
type Edit[A, B] = (Node.Name, Node.Edit[A, B]) |
44384 | 69 |
type Edit_Text = Edit[Text.Edit, Text.Perspective] |
52849 | 70 |
type Edit_Command = Edit[Command.Edit, Command.Perspective] |
38151 | 71 |
|
75393 | 72 |
object Node { |
52887 | 73 |
/* header and name */ |
74 |
||
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
75 |
sealed case class Header( |
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70636
diff
changeset
|
76 |
imports_pos: List[(Name, Position.T)] = Nil, |
63020 | 77 |
keywords: Thy_Header.Keywords = Nil, |
63579 | 78 |
abbrevs: Thy_Header.Abbrevs = Nil, |
75393 | 79 |
errors: List[String] = Nil |
80 |
) { |
|
72669 | 81 |
def imports_offset: Map[Int, Name] = |
82 |
(for { (name, Position.Offset(i)) <- imports_pos } yield i -> name).toMap |
|
83 |
||
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70636
diff
changeset
|
84 |
def imports: List[Name] = imports_pos.map(_._1) |
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70636
diff
changeset
|
85 |
|
66773 | 86 |
def append_errors(msgs: List[String]): Header = |
87 |
copy(errors = errors ::: msgs) |
|
54549
2a3053472ec3
actually expose errors of cumulative theory dependencies;
wenzelm
parents:
54530
diff
changeset
|
88 |
|
2a3053472ec3
actually expose errors of cumulative theory dependencies;
wenzelm
parents:
54530
diff
changeset
|
89 |
def cat_errors(msg2: String): Header = |
62492 | 90 |
copy(errors = errors.map(msg1 => Exn.cat_message(msg1, msg2))) |
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
91 |
} |
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
92 |
|
71601 | 93 |
val no_header: Header = Header() |
63020 | 94 |
def bad_header(msg: String): Header = Header(errors = List(msg)) |
46737 | 95 |
|
75393 | 96 |
object Name { |
71601 | 97 |
val empty: Name = Name("") |
46723 | 98 |
|
75393 | 99 |
object Ordering extends scala.math.Ordering[Name] { |
46723 | 100 |
def compare(name1: Name, name2: Name): Int = name1.node compare name2.node |
101 |
} |
|
70636 | 102 |
|
70674
29bb1ebb188f
clarified signature: proper Document.Node.Ordering conforming to equality (e.g. required in situations where theory names are ambiguous due to overlapping session directories);
wenzelm
parents:
70650
diff
changeset
|
103 |
type Graph[A] = isabelle.Graph[Node.Name, A] |
29bb1ebb188f
clarified signature: proper Document.Node.Ordering conforming to equality (e.g. required in situations where theory names are ambiguous due to overlapping session directories);
wenzelm
parents:
70650
diff
changeset
|
104 |
|
70692 | 105 |
def make_graph[A](entries: List[((Name, A), List[Name])]): Graph[A] = |
106 |
Graph.make(entries, symmetric = true)(Ordering) |
|
44957
098dd95349e7
more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents:
44676
diff
changeset
|
107 |
} |
52887 | 108 |
|
75393 | 109 |
sealed case class Name(node: String, master_dir: String = "", theory: String = "") { |
44615 | 110 |
override def hashCode: Int = node.hashCode |
111 |
override def equals(that: Any): Boolean = |
|
112 |
that match { |
|
113 |
case other: Name => node == other.node |
|
114 |
case _ => false |
|
115 |
} |
|
54509
1f77110c94ef
maintain document model for all files, with document view for theory only, and special blob for non-theory files;
wenzelm
parents:
54462
diff
changeset
|
116 |
|
66849 | 117 |
def path: Path = Path.explode(File.standard_path(node)) |
70676 | 118 |
def master_dir_path: Path = Path.explode(File.standard_path(master_dir)) |
66716 | 119 |
|
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
120 |
def expand: Name = |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
121 |
Name(path.expand.implode, master_dir_path.expand.implode, theory) |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
122 |
def symbolic: Name = |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
123 |
Name(path.implode_symbolic, master_dir_path.implode_symbolic, theory) |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
124 |
|
59319 | 125 |
def is_theory: Boolean = theory.nonEmpty |
65409 | 126 |
|
65439 | 127 |
def theory_base_name: String = Long_Name.base_name(theory) |
128 |
||
54510 | 129 |
override def toString: String = if (is_theory) theory else node |
56801
8dd9df88f647
some support for session-qualified theories: allow to refer to resources via qualified name instead of odd file-system path;
wenzelm
parents:
56746
diff
changeset
|
130 |
|
8dd9df88f647
some support for session-qualified theories: allow to refer to resources via qualified name instead of odd file-system path;
wenzelm
parents:
56746
diff
changeset
|
131 |
def map(f: String => String): Name = copy(f(node), f(master_dir), theory) |
66195 | 132 |
def map_theory(f: String => String): Name = copy(node, master_dir, f(theory)) |
67943 | 133 |
|
134 |
def json: JSON.Object.T = |
|
135 |
JSON.Object("node_name" -> node, "theory_name" -> theory) |
|
44615 | 136 |
} |
137 |
||
75393 | 138 |
sealed case class Entry(name: Node.Name, header: Node.Header) { |
68306
d575281e18d0
clarified signature: Known.theories retains Document.Node.Entry (with header);
wenzelm
parents:
68300
diff
changeset
|
139 |
def map(f: String => String): Entry = copy(name = name.map(f)) |
d575281e18d0
clarified signature: Known.theories retains Document.Node.Entry (with header);
wenzelm
parents:
68300
diff
changeset
|
140 |
|
66714 | 141 |
override def toString: String = name.toString |
142 |
} |
|
143 |
||
52887 | 144 |
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
145 |
/* node overlays */ |
52887 | 146 |
|
75393 | 147 |
object Overlays { |
52976 | 148 |
val empty = new Overlays(Multi_Map.empty) |
52887 | 149 |
} |
150 |
||
75393 | 151 |
final class Overlays private(rep: Multi_Map[Command, (String, List[String])]) { |
52887 | 152 |
def commands: Set[Command] = rep.keySet |
153 |
def is_empty: Boolean = rep.isEmpty |
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
154 |
def dest: List[(Command, (String, List[String]))] = rep.iterator.toList |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
155 |
def insert(cmd: Command, fn: String, args: List[String]): Overlays = |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
156 |
new Overlays(rep.insert(cmd, (fn, args))) |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
157 |
def remove(cmd: Command, fn: String, args: List[String]): Overlays = |
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
158 |
new Overlays(rep.remove(cmd, (fn, args))) |
55800 | 159 |
|
160 |
override def toString: String = rep.mkString("Node.Overlays(", ",", ")") |
|
52887 | 161 |
} |
162 |
||
163 |
||
164 |
/* edits */ |
|
165 |
||
75393 | 166 |
sealed abstract class Edit[A, B] { |
167 |
def foreach(f: A => Unit): Unit = { |
|
44156 | 168 |
this match { |
44383 | 169 |
case Edits(es) => es.foreach(f) |
170 |
case _ => |
|
44156 | 171 |
} |
44383 | 172 |
} |
57621 | 173 |
|
174 |
def is_void: Boolean = |
|
175 |
this match { |
|
176 |
case Edits(Nil) => true |
|
177 |
case _ => false |
|
178 |
} |
|
44156 | 179 |
} |
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56314
diff
changeset
|
180 |
case class Blob[A, B](blob: Document.Blob) extends Edit[A, B] |
54562
301a721af68b
clarified node edits sent to prover -- Clear/Blob only required for text edits within editor;
wenzelm
parents:
54549
diff
changeset
|
181 |
|
44384 | 182 |
case class Edits[A, B](edits: List[A]) extends Edit[A, B] |
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
183 |
case class Deps[A, B](header: Header) extends Edit[A, B] |
52849 | 184 |
case class Perspective[A, B](required: Boolean, visible: B, overlays: Overlays) extends Edit[A, B] |
57610 | 185 |
|
186 |
||
187 |
/* perspective */ |
|
188 |
||
52808
143f225e50f5
allow explicit indication of required node: full eval, no prints;
wenzelm
parents:
52568
diff
changeset
|
189 |
type Perspective_Text = Perspective[Text.Edit, Text.Perspective] |
52849 | 190 |
type Perspective_Command = Perspective[Command.Edit, Command.Perspective] |
44156 | 191 |
|
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
192 |
val no_perspective_text: Perspective_Text = |
57610 | 193 |
Perspective(false, Text.Perspective.empty, Overlays.empty) |
194 |
||
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
195 |
val no_perspective_command: Perspective_Command = |
57614 | 196 |
Perspective(false, Command.Perspective.empty, Overlays.empty) |
197 |
||
64867 | 198 |
def is_no_perspective_text(perspective: Perspective_Text): Boolean = |
199 |
!perspective.required && |
|
200 |
perspective.visible.is_empty && |
|
201 |
perspective.overlays.is_empty |
|
202 |
||
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
203 |
def is_no_perspective_command(perspective: Perspective_Command): Boolean = |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
204 |
!perspective.required && |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
205 |
perspective.visible.is_empty && |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
206 |
perspective.overlays.is_empty |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
207 |
|
52887 | 208 |
|
209 |
/* commands */ |
|
210 |
||
75393 | 211 |
object Commands { |
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
212 |
def apply(commands: Linear_Set[Command]): Commands = new Commands(commands) |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
213 |
val empty: Commands = apply(Linear_Set.empty) |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
214 |
|
75393 | 215 |
def starts( |
216 |
commands: Iterator[Command], |
|
217 |
offset: Text.Offset = 0 |
|
218 |
) : Iterator[(Command, Text.Offset)] = { |
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
219 |
var i = offset |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
220 |
for (command <- commands) yield { |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
221 |
val start = i |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
222 |
i += command.length |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
223 |
(command, start) |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
224 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
225 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
226 |
|
75393 | 227 |
def starts_pos( |
228 |
commands: Iterator[Command], |
|
229 |
pos: Token.Pos = Token.Pos.start |
|
230 |
) : Iterator[(Command, Token.Pos)] = { |
|
67895 | 231 |
var p = pos |
232 |
for (command <- commands) yield { |
|
233 |
val start = p |
|
73359 | 234 |
p = command.span.content.foldLeft(p)(_.advance(_)) |
67895 | 235 |
(command, start) |
236 |
} |
|
237 |
} |
|
238 |
||
56398
15d0821c8667
afford larger full_index, to save a few milliseconds during rendering (notably text_overview);
wenzelm
parents:
56394
diff
changeset
|
239 |
private val block_size = 256 |
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
240 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
241 |
|
75393 | 242 |
final class Commands private(val commands: Linear_Set[Command]) { |
56314 | 243 |
lazy val load_commands: List[Command] = |
59319 | 244 |
commands.iterator.filter(cmd => cmd.blobs.nonEmpty).toList |
54462 | 245 |
|
75393 | 246 |
private lazy val full_index: (Array[(Command, Text.Offset)], Text.Range) = { |
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
247 |
val blocks = new mutable.ListBuffer[(Command, Text.Offset)] |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
248 |
var next_block = 0 |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
249 |
var last_stop = 0 |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
250 |
for ((command, start) <- Commands.starts(commands.iterator)) { |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
251 |
last_stop = start + command.length |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
252 |
while (last_stop + 1 > next_block) { |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
253 |
blocks += (command -> start) |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
254 |
next_block += Commands.block_size |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
255 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
256 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
257 |
(blocks.toArray, Text.Range(0, last_stop)) |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
258 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
259 |
|
66043 | 260 |
private def full_range: Text.Range = full_index._2 |
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
261 |
|
75393 | 262 |
def iterator(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] = { |
59319 | 263 |
if (commands.nonEmpty && full_range.contains(i)) { |
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
264 |
val (cmd0, start0) = full_index._1(i / Commands.block_size) |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
265 |
Node.Commands.starts(commands.iterator(cmd0), start0) dropWhile { |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
266 |
case (cmd, start) => start + cmd.length <= i } |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
267 |
} |
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
268 |
else Iterator.empty |
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
269 |
} |
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
270 |
} |
57614 | 271 |
|
272 |
val empty: Node = new Node() |
|
38151 | 273 |
} |
274 |
||
46712 | 275 |
final class Node private( |
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56314
diff
changeset
|
276 |
val get_blob: Option[Document.Blob] = None, |
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
277 |
val header: Node.Header = Node.no_header, |
63584
68751fe1c036
tuned signature -- prover-independence is presently theoretical;
wenzelm
parents:
63579
diff
changeset
|
278 |
val syntax: Option[Outer_Syntax] = None, |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
279 |
val text_perspective: Text.Perspective = Text.Perspective.empty, |
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
280 |
val perspective: Node.Perspective_Command = Node.no_perspective_command, |
75393 | 281 |
_commands: Node.Commands = Node.Commands.empty |
282 |
) { |
|
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
283 |
def is_empty: Boolean = |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
284 |
get_blob.isEmpty && |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
285 |
header == Node.no_header && |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
286 |
text_perspective.is_empty && |
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
287 |
Node.is_no_perspective_command(perspective) && |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
288 |
commands.isEmpty |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
289 |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59695
diff
changeset
|
290 |
def has_header: Boolean = header != Node.no_header |
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59695
diff
changeset
|
291 |
|
69556 | 292 |
override def toString: String = |
293 |
if (is_empty) "empty" |
|
294 |
else if (get_blob.isDefined) "blob" |
|
295 |
else "node" |
|
296 |
||
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
297 |
def commands: Linear_Set[Command] = _commands.commands |
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
298 |
def load_commands: List[Command] = _commands.load_commands |
64799 | 299 |
def load_commands_changed(doc_blobs: Blobs): Boolean = |
300 |
load_commands.exists(_.blobs_changed(doc_blobs)) |
|
57615
df1b3452d71c
more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents:
57614
diff
changeset
|
301 |
|
64799 | 302 |
def init_blob(blob: Blob): Node = new Node(get_blob = Some(blob.unchanged)) |
55435
662e0fd39823
maintain blob edits within history, which is important for Snapshot.convert/revert;
wenzelm
parents:
55434
diff
changeset
|
303 |
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
304 |
def update_header(new_header: Node.Header): Node = |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
305 |
new Node(get_blob, new_header, syntax, text_perspective, perspective, _commands) |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57976
diff
changeset
|
306 |
|
63584
68751fe1c036
tuned signature -- prover-independence is presently theoretical;
wenzelm
parents:
63579
diff
changeset
|
307 |
def update_syntax(new_syntax: Option[Outer_Syntax]): Node = |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
308 |
new Node(get_blob, header, new_syntax, text_perspective, perspective, _commands) |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
309 |
|
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
310 |
def update_perspective( |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
311 |
new_text_perspective: Text.Perspective, |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
312 |
new_perspective: Node.Perspective_Command): Node = |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
313 |
new Node(get_blob, header, syntax, new_text_perspective, new_perspective, _commands) |
46680 | 314 |
|
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
315 |
def edit_perspective: Node.Edit[Text.Edit, Text.Perspective] = |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
316 |
Node.Perspective(perspective.required, text_perspective, perspective.overlays) |
46680 | 317 |
|
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
318 |
def same_perspective( |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
319 |
other_text_perspective: Text.Perspective, |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
320 |
other_perspective: Node.Perspective_Command): Boolean = |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
321 |
text_perspective == other_text_perspective && |
52849 | 322 |
perspective.required == other_perspective.required && |
323 |
perspective.visible.same(other_perspective.visible) && |
|
324 |
perspective.overlays == other_perspective.overlays |
|
52808
143f225e50f5
allow explicit indication of required node: full eval, no prints;
wenzelm
parents:
52568
diff
changeset
|
325 |
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
326 |
def update_commands(new_commands: Linear_Set[Command]): Node = |
52918
038458a4d11b
proper low-level comparison -- heed warning by Scala compiler;
wenzelm
parents:
52901
diff
changeset
|
327 |
if (new_commands eq _commands.commands) this |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
328 |
else |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
329 |
new Node(get_blob, header, syntax, text_perspective, perspective, |
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
330 |
Node.Commands(new_commands)) |
38151 | 331 |
|
56373
0605d90be6fc
tuned signature -- more explicit iterator terminology;
wenzelm
parents:
56372
diff
changeset
|
332 |
def command_iterator(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] = |
0605d90be6fc
tuned signature -- more explicit iterator terminology;
wenzelm
parents:
56372
diff
changeset
|
333 |
_commands.iterator(i) |
38151 | 334 |
|
56373
0605d90be6fc
tuned signature -- more explicit iterator terminology;
wenzelm
parents:
56372
diff
changeset
|
335 |
def command_iterator(range: Text.Range): Iterator[(Command, Text.Offset)] = |
0605d90be6fc
tuned signature -- more explicit iterator terminology;
wenzelm
parents:
56372
diff
changeset
|
336 |
command_iterator(range.start) takeWhile { case (_, start) => start < range.stop } |
38151 | 337 |
|
38879
dde403450419
Document.Node: significant speedup of command_range etc. via lazy full_index;
wenzelm
parents:
38872
diff
changeset
|
338 |
def command_start(cmd: Command): Option[Text.Offset] = |
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
339 |
Node.Commands.starts(commands.iterator).find(_._1 == cmd).map(_._2) |
67247 | 340 |
|
67251 | 341 |
def source: String = |
67247 | 342 |
get_blob match { |
67265
f32287c95432
store full blob source for the sake of markup_to_XML;
wenzelm
parents:
67264
diff
changeset
|
343 |
case Some(blob) => blob.source |
67247 | 344 |
case None => command_iterator(0).map({ case (cmd, _) => cmd.source }).mkString |
345 |
} |
|
38151 | 346 |
} |
347 |
||
348 |
||
46723 | 349 |
/* development graph */ |
350 |
||
75393 | 351 |
object Nodes { |
46723 | 352 |
val empty: Nodes = new Nodes(Graph.empty(Node.Name.Ordering)) |
353 |
} |
|
354 |
||
75393 | 355 |
final class Nodes private(graph: Graph[Node.Name, Node]) { |
46723 | 356 |
def apply(name: Node.Name): Node = |
357 |
graph.default_node(name, Node.empty).get_node(name) |
|
358 |
||
75393 | 359 |
def is_suppressed(name: Node.Name): Boolean = { |
57619 | 360 |
val graph1 = graph.default_node(name, Node.empty) |
361 |
graph1.is_maximal(name) && graph1.get_node(name).is_empty |
|
362 |
} |
|
57617 | 363 |
|
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
364 |
def purge_suppressed: Option[Nodes] = |
71601 | 365 |
graph.keys_iterator.filter(is_suppressed).toList match { |
67112 | 366 |
case Nil => None |
73359 | 367 |
case del => Some(new Nodes(del.foldLeft(graph)(_.del_node(_)))) |
67112 | 368 |
} |
67110
3156faac30a7
purge hidden nodes more thoroughly: is_hidden may become true only later;
wenzelm
parents:
67014
diff
changeset
|
369 |
|
75393 | 370 |
def + (entry: (Node.Name, Node)): Nodes = { |
46723 | 371 |
val (name, node) = entry |
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70636
diff
changeset
|
372 |
val imports = node.header.imports |
46723 | 373 |
val graph1 = |
73359 | 374 |
imports.foldLeft(graph.default_node(name, Node.empty)) { |
375 |
case (g, p) => g.default_node(p, Node.empty) |
|
376 |
} |
|
377 |
val graph2 = |
|
378 |
graph1.imm_preds(name).foldLeft(graph1) { case (g, dep) => g.del_edge(dep, name) } |
|
379 |
val graph3 = imports.foldLeft(graph2) { case (g, dep) => g.add_edge(dep, name) } |
|
67110
3156faac30a7
purge hidden nodes more thoroughly: is_hidden may become true only later;
wenzelm
parents:
67014
diff
changeset
|
380 |
new Nodes(graph3.map_node(name, _ => node)) |
46723 | 381 |
} |
382 |
||
68321 | 383 |
def domain: Set[Node.Name] = graph.domain |
384 |
||
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56354
diff
changeset
|
385 |
def iterator: Iterator[(Node.Name, Node)] = |
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56354
diff
changeset
|
386 |
graph.iterator.map({ case (name, (node, _)) => (name, node) }) |
46723 | 387 |
|
70539
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70284
diff
changeset
|
388 |
def theory_name(theory: String): Option[Node.Name] = |
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70284
diff
changeset
|
389 |
graph.keys_iterator.find(name => name.theory == theory) |
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70284
diff
changeset
|
390 |
|
64799 | 391 |
def commands_loading(file_name: Node.Name): List[Command] = |
54528 | 392 |
(for { |
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56354
diff
changeset
|
393 |
(_, node) <- iterator |
56314 | 394 |
cmd <- node.load_commands.iterator |
54530
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54528
diff
changeset
|
395 |
name <- cmd.blobs_names.iterator |
54528 | 396 |
if name == file_name |
397 |
} yield cmd).toList |
|
398 |
||
46942
f5c2d66faa04
basic support for outer syntax keywords in theory header;
wenzelm
parents:
46941
diff
changeset
|
399 |
def descendants(names: List[Node.Name]): List[Node.Name] = graph.all_succs(names) |
72065
11dc8929832d
clarified order --- proper sorting of requirements;
wenzelm
parents:
71601
diff
changeset
|
400 |
def requirements(names: List[Node.Name]): List[Node.Name] = graph.all_preds_rev(names) |
46723 | 401 |
def topological_order: List[Node.Name] = graph.topological_order |
56337 | 402 |
|
403 |
override def toString: String = topological_order.mkString("Nodes(", ",", ")") |
|
46723 | 404 |
} |
405 |
||
406 |
||
38424 | 407 |
|
408 |
/** versioning **/ |
|
409 |
||
410 |
/* particular document versions */ |
|
34485 | 411 |
|
75393 | 412 |
object Version { |
46681 | 413 |
val init: Version = new Version() |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57976
diff
changeset
|
414 |
def make(nodes: Nodes): Version = new Version(Document_ID.make(), nodes) |
67112 | 415 |
|
75393 | 416 |
def purge_future( |
417 |
versions: Map[Document_ID.Version, Version], |
|
418 |
future: Future[Version] |
|
419 |
) : Future[Version] = { |
|
68066
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
420 |
if (future.is_finished) { |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
421 |
val version = future.join |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
422 |
versions.get(version.id) match { |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
423 |
case Some(version1) if !(version eq version1) => Future.value(version1) |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
424 |
case _ => future |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
425 |
} |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
426 |
} |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
427 |
else future |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
428 |
} |
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
429 |
|
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
430 |
def purge_suppressed( |
75393 | 431 |
versions: Map[Document_ID.Version, Version] |
432 |
): Map[Document_ID.Version, Version] = { |
|
73359 | 433 |
(for ((id, v) <- versions.iterator; v1 <- v.purge_suppressed) yield (id, v1)). |
434 |
foldLeft(versions)(_ + _) |
|
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
435 |
} |
38417 | 436 |
} |
437 |
||
46712 | 438 |
final class Version private( |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
439 |
val id: Document_ID.Version = Document_ID.none, |
75393 | 440 |
val nodes: Nodes = Nodes.empty |
441 |
) { |
|
55777 | 442 |
override def toString: String = "Version(" + id + ")" |
67110
3156faac30a7
purge hidden nodes more thoroughly: is_hidden may become true only later;
wenzelm
parents:
67014
diff
changeset
|
443 |
|
68299
0b5a23477911
clarified signature -- avoid confusion with Resources.is_hidden;
wenzelm
parents:
68114
diff
changeset
|
444 |
def purge_suppressed: Option[Version] = |
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
445 |
nodes.purge_suppressed.map(new Version(id, _)) |
46941 | 446 |
} |
34660 | 447 |
|
34859 | 448 |
|
38424 | 449 |
/* changes of plain text, eventually resulting in document edits */ |
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
450 |
|
75393 | 451 |
object Change { |
46678 | 452 |
val init: Change = new Change() |
453 |
||
454 |
def make(previous: Future[Version], edits: List[Edit_Text], version: Future[Version]): Change = |
|
57620
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
455 |
new Change(Some(previous), edits.reverse, version) |
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
456 |
} |
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
457 |
|
46712 | 458 |
final class Change private( |
46677 | 459 |
val previous: Option[Future[Version]] = Some(Future.value(Version.init)), |
57620
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
460 |
val rev_edits: List[Edit_Text] = Nil, |
75393 | 461 |
val version: Future[Version] = Future.value(Version.init) |
462 |
) { |
|
44672 | 463 |
def is_finished: Boolean = |
464 |
(previous match { case None => true case Some(future) => future.is_finished }) && |
|
465 |
version.is_finished |
|
466 |
||
46678 | 467 |
def truncate: Change = new Change(None, Nil, version) |
68066
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
468 |
|
75393 | 469 |
def purge(versions: Map[Document_ID.Version, Version]): Option[Change] = { |
68066
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
470 |
val previous1 = previous.map(Version.purge_future(versions, _)) |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
471 |
val version1 = Version.purge_future(versions, version) |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
472 |
if ((previous eq previous1) && (version eq version1)) None |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
473 |
else Some(new Change(previous1, rev_edits, version1)) |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
474 |
} |
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
475 |
} |
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
476 |
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
477 |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
478 |
/* history navigation */ |
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
479 |
|
75393 | 480 |
object History { |
46679 | 481 |
val init: History = new History() |
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
482 |
} |
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
483 |
|
46712 | 484 |
final class History private( |
75393 | 485 |
val undo_list: List[Change] = List(Change.init) // non-empty list |
486 |
) { |
|
67114 | 487 |
override def toString: String = "History(" + undo_list.length + ")" |
488 |
||
46679 | 489 |
def tip: Change = undo_list.head |
490 |
def + (change: Change): History = new History(change :: undo_list) |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
491 |
|
75393 | 492 |
def prune(check: Change => Boolean, retain: Int): Option[(List[Change], History)] = { |
46679 | 493 |
val n = undo_list.iterator.zipWithIndex.find(p => check(p._1)).get._2 + 1 |
494 |
val (retained, dropped) = undo_list.splitAt(n max retain) |
|
495 |
||
496 |
retained.splitAt(retained.length - 1) match { |
|
497 |
case (prefix, List(last)) => Some(dropped, new History(prefix ::: List(last.truncate))) |
|
498 |
case _ => None |
|
499 |
} |
|
500 |
} |
|
68066
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
501 |
|
75393 | 502 |
def purge(versions: Map[Document_ID.Version, Version]): History = { |
68066
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
503 |
val undo_list1 = undo_list.map(_.purge(versions)) |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
504 |
if (undo_list1.forall(_.isEmpty)) this |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
505 |
else new History(for ((a, b) <- undo_list1 zip undo_list) yield a.getOrElse(b)) |
63f03ee4057e
purge history more thoroughly (see also 3156faac30a7);
wenzelm
parents:
67943
diff
changeset
|
506 |
} |
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
507 |
} |
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
508 |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
509 |
|
72818 | 510 |
/* snapshot: persistent user-view of document state */ |
38424 | 511 |
|
75393 | 512 |
object Snapshot { |
71601 | 513 |
val init: Snapshot = State.init.snapshot() |
52972 | 514 |
} |
515 |
||
72821 | 516 |
class Snapshot private[Document]( |
72818 | 517 |
val state: State, |
518 |
val version: Version, |
|
519 |
val node_name: Node.Name, |
|
72820 | 520 |
edits: List[Text.Edit], |
75393 | 521 |
val snippet_command: Option[Command] |
522 |
) { |
|
72821 | 523 |
override def toString: String = |
524 |
"Snapshot(node = " + node_name.node + ", version = " + version.id + |
|
525 |
(if (is_outdated) ", outdated" else "") + ")" |
|
526 |
||
527 |
||
72822 | 528 |
/* nodes */ |
529 |
||
72823 | 530 |
def get_node(name: Node.Name): Node = version.nodes(name) |
531 |
||
532 |
val node: Node = get_node(node_name) |
|
72822 | 533 |
|
534 |
def node_files: List[Node.Name] = |
|
72829
a28a4105883f
avoid duplicate entries: snippet_command is defined within node;
wenzelm
parents:
72823
diff
changeset
|
535 |
node_name :: node.load_commands.flatMap(_.blobs_names) |
72822 | 536 |
|
537 |
||
72820 | 538 |
/* edits */ |
539 |
||
540 |
def is_outdated: Boolean = edits.nonEmpty |
|
541 |
||
542 |
private lazy val reverse_edits = edits.reverse |
|
543 |
||
544 |
def convert(offset: Text.Offset): Text.Offset = |
|
73359 | 545 |
edits.foldLeft(offset) { case (i, edit) => edit.convert(i) } |
72820 | 546 |
def revert(offset: Text.Offset): Text.Offset = |
73359 | 547 |
reverse_edits.foldLeft(offset) { case (i, edit) => edit.revert(i) } |
72820 | 548 |
|
549 |
def convert(range: Text.Range): Text.Range = range.map(convert) |
|
550 |
def revert(range: Text.Range): Text.Range = range.map(revert) |
|
551 |
||
52972 | 552 |
|
72821 | 553 |
/* theory load commands */ |
554 |
||
555 |
val commands_loading: List[Command] = |
|
556 |
if (node_name.is_theory) Nil |
|
557 |
else version.nodes.commands_loading(node_name) |
|
558 |
||
559 |
def commands_loading_ranges(pred: Node.Name => Boolean): List[Text.Range] = |
|
560 |
(for { |
|
561 |
cmd <- node.load_commands.iterator |
|
562 |
blob_name <- cmd.blobs_names.iterator |
|
563 |
if pred(blob_name) |
|
564 |
start <- node.command_start(cmd) |
|
565 |
} yield convert(cmd.core_range + start)).toList |
|
566 |
||
567 |
||
568 |
/* command as add-on snippet */ |
|
569 |
||
75393 | 570 |
def snippet(command: Command): Snapshot = { |
72718 | 571 |
val node_name = command.node_name |
572 |
||
573 |
val nodes0 = version.nodes |
|
574 |
val nodes1 = nodes0 + (node_name -> nodes0(node_name).update_commands(Linear_Set(command))) |
|
575 |
val version1 = Document.Version.make(nodes1) |
|
576 |
||
577 |
val edits: List[Edit_Text] = |
|
578 |
List(node_name -> Node.Edits(List(Text.Edit.insert(0, command.source)))) |
|
579 |
||
580 |
val state0 = state.define_command(command) |
|
581 |
val state1 = |
|
582 |
state0.continue_history(Future.value(version), edits, Future.value(version1)) |
|
583 |
.define_version(version1, state0.the_assignment(version)) |
|
584 |
.assign(version1.id, Nil, List(command.id -> List(Document_ID.make())))._2 |
|
585 |
||
72818 | 586 |
state1.snapshot(node_name = node_name, snippet_command = Some(command)) |
72718 | 587 |
} |
588 |
||
72821 | 589 |
|
590 |
/* XML markup */ |
|
591 |
||
72723 | 592 |
def xml_markup( |
72821 | 593 |
range: Text.Range = Text.Range.full, |
594 |
elements: Markup.Elements = Markup.Elements.full): XML.Body = |
|
595 |
state.xml_markup(version, node_name, range = range, elements = elements) |
|
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
596 |
|
75393 | 597 |
def xml_markup_blobs( |
598 |
elements: Markup.Elements = Markup.Elements.full |
|
599 |
) : List[(Path, XML.Body)] = { |
|
72818 | 600 |
snippet_command match { |
72817
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
601 |
case None => Nil |
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
602 |
case Some(command) => |
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
603 |
for (Exn.Res(blob) <- command.blobs) |
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
604 |
yield { |
72962 | 605 |
val bytes = blob.read_file |
606 |
val text = bytes.text |
|
607 |
val xml = |
|
608 |
if (Bytes(text) == bytes) { |
|
609 |
val markup = command.init_markups(Command.Markup_Index.blob(blob)) |
|
610 |
markup.to_XML(Text.Range(0, text.length), text, elements) |
|
611 |
} |
|
612 |
else Nil |
|
613 |
blob.src_path -> xml |
|
72817
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
614 |
} |
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
615 |
} |
1c378ab75d48
clarified signature, notably access to blob files;
wenzelm
parents:
72816
diff
changeset
|
616 |
} |
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
617 |
|
72821 | 618 |
|
619 |
/* messages */ |
|
620 |
||
72869 | 621 |
lazy val messages: List[(XML.Elem, Position.T)] = |
72821 | 622 |
(for { |
623 |
(command, start) <- |
|
624 |
Document.Node.Commands.starts_pos( |
|
625 |
node.commands.iterator, Token.Pos.file(node_name.node)) |
|
626 |
pos = command.span.keyword_pos(start).position(command.span.name) |
|
72869 | 627 |
(_, elem) <- state.command_results(version, command).iterator |
628 |
} yield (elem, pos)).toList |
|
72821 | 629 |
|
630 |
||
631 |
/* exports */ |
|
632 |
||
633 |
lazy val exports: List[Export.Entry] = |
|
634 |
state.node_exports(version, node_name).iterator.map(_._2).toList |
|
635 |
||
636 |
lazy val exports_map: Map[String, Export.Entry] = |
|
637 |
(for (entry <- exports.iterator) yield (entry.name, entry)).toMap |
|
638 |
||
639 |
||
640 |
/* find command */ |
|
641 |
||
642 |
def find_command(id: Document_ID.Generic): Option[(Node, Command)] = |
|
643 |
state.lookup_id(id) match { |
|
644 |
case None => None |
|
645 |
case Some(st) => |
|
646 |
val command = st.command |
|
72823 | 647 |
val command_node = get_node(command.node_name) |
648 |
if (command_node.commands.contains(command)) Some((command_node, command)) else None |
|
72821 | 649 |
} |
66040 | 650 |
|
64665 | 651 |
def find_command_position(id: Document_ID.Generic, offset: Symbol.Offset) |
72821 | 652 |
: Option[Line.Node_Position] = |
653 |
for ((node, command) <- find_command(id)) |
|
654 |
yield { |
|
655 |
val name = command.node_name.node |
|
656 |
val sources_iterator = |
|
657 |
node.commands.iterator.takeWhile(_ != command).map(_.source) ++ |
|
658 |
(if (offset == 0) Iterator.empty |
|
659 |
else Iterator.single(command.source(Text.Range(0, command.chunk.decode(offset))))) |
|
73359 | 660 |
val pos = sources_iterator.foldLeft(Line.Position.zero)(_.advance(_)) |
72821 | 661 |
Line.Node_Position(name, pos) |
662 |
} |
|
663 |
||
664 |
def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command] = |
|
665 |
if (other_node_name.is_theory) { |
|
72823 | 666 |
val other_node = get_node(other_node_name) |
72821 | 667 |
val iterator = other_node.command_iterator(revert(offset) max 0) |
668 |
if (iterator.hasNext) { |
|
73344 | 669 |
val (command0, _) = iterator.next() |
72821 | 670 |
other_node.commands.reverse.iterator(command0).find(command => !command.is_ignored) |
671 |
} |
|
672 |
else other_node.commands.reverse.iterator.find(command => !command.is_ignored) |
|
673 |
} |
|
674 |
else version.nodes.commands_loading(other_node_name).headOption |
|
675 |
||
676 |
||
677 |
/* command results */ |
|
678 |
||
679 |
def command_results(range: Text.Range): Command.Results = |
|
680 |
Command.State.merge_results( |
|
75393 | 681 |
select[List[Command.State]](range, Markup.Elements.full, |
682 |
command_states => { case _ => Some(command_states) }).flatMap(_.info)) |
|
72821 | 683 |
|
684 |
def command_results(command: Command): Command.Results = |
|
685 |
state.command_results(version, command) |
|
686 |
||
687 |
||
688 |
/* command ids: static and dynamic */ |
|
689 |
||
690 |
def command_id_map: Map[Document_ID.Generic, Command] = |
|
72823 | 691 |
state.command_id_map(version, get_node(node_name).commands) |
72821 | 692 |
|
693 |
||
694 |
/* cumulate markup */ |
|
64665 | 695 |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55650
diff
changeset
|
696 |
def cumulate[A]( |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55620
diff
changeset
|
697 |
range: Text.Range, |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55620
diff
changeset
|
698 |
info: A, |
56743 | 699 |
elements: Markup.Elements, |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56337
diff
changeset
|
700 |
result: List[Command.State] => (A, Text.Markup) => Option[A], |
75393 | 701 |
status: Boolean = false |
702 |
): List[Text.Info[A]] = { |
|
72821 | 703 |
val former_range = revert(range).inflate_singularity |
704 |
val (chunk_name, command_iterator) = |
|
705 |
commands_loading.headOption match { |
|
706 |
case None => (Symbol.Text_Chunk.Default, node.command_iterator(former_range)) |
|
707 |
case Some(command) => (Symbol.Text_Chunk.File(node_name.node), Iterator((command, 0))) |
|
708 |
} |
|
709 |
val markup_index = Command.Markup_Index(status, chunk_name) |
|
710 |
(for { |
|
711 |
(command, command_start) <- command_iterator |
|
712 |
chunk <- command.chunks.get(chunk_name).iterator |
|
713 |
states = state.command_states(version, command) |
|
714 |
res = result(states) |
|
715 |
markup_range <- (former_range - command_start).try_restrict(chunk.range).iterator |
|
716 |
markup = Command.State.merge_markup(states, markup_index, markup_range, elements) |
|
717 |
Text.Info(r0, a) <- markup.cumulate[A](markup_range, info, elements, |
|
718 |
{ |
|
719 |
case (a, Text.Info(r0, b)) => res(a, Text.Info(convert(r0 + command_start), b)) |
|
720 |
}).iterator |
|
721 |
r1 <- convert(r0 + command_start).try_restrict(range).iterator |
|
722 |
} yield Text.Info(r1, a)).toList |
|
723 |
} |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55650
diff
changeset
|
724 |
|
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55650
diff
changeset
|
725 |
def select[A]( |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55620
diff
changeset
|
726 |
range: Text.Range, |
56743 | 727 |
elements: Markup.Elements, |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56337
diff
changeset
|
728 |
result: List[Command.State] => Text.Markup => Option[A], |
75393 | 729 |
status: Boolean = false |
730 |
): List[Text.Info[A]] = { |
|
731 |
def result1(states: List[Command.State]): (Option[A], Text.Markup) => Option[Option[A]] = { |
|
72821 | 732 |
val res = result(states) |
733 |
(_: Option[A], x: Text.Markup) => |
|
734 |
res(x) match { |
|
735 |
case None => None |
|
736 |
case some => Some(some) |
|
737 |
} |
|
738 |
} |
|
739 |
for (Text.Info(r, Some(x)) <- cumulate(range, None, elements, result1, status)) |
|
740 |
yield Text.Info(r, x) |
|
741 |
} |
|
38424 | 742 |
} |
743 |
||
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55801
diff
changeset
|
744 |
|
64814 | 745 |
/* model */ |
746 |
||
75393 | 747 |
trait Session { |
65221 | 748 |
def resources: Resources |
749 |
} |
|
750 |
||
75393 | 751 |
trait Model { |
64814 | 752 |
def session: Session |
64827
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
753 |
def is_stable: Boolean |
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
754 |
def snapshot(): Snapshot |
64814 | 755 |
|
65356 | 756 |
def node_name: Node.Name |
64814 | 757 |
def is_theory: Boolean = node_name.is_theory |
758 |
override def toString: String = node_name.toString |
|
759 |
||
67014 | 760 |
def get_text(range: Text.Range): Option[String] |
66114 | 761 |
|
64815 | 762 |
def node_required: Boolean |
65356 | 763 |
def get_blob: Option[Blob] |
66150 | 764 |
def bibtex_entries: List[Text.Info[String]] |
64815 | 765 |
|
64827
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
766 |
def node_edits( |
64867 | 767 |
node_header: Node.Header, |
768 |
text_edits: List[Text.Edit], |
|
75393 | 769 |
perspective: Node.Perspective_Text |
770 |
): List[Edit_Text] = { |
|
64827
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
771 |
val edits: List[Node.Edit[Text.Edit, Text.Perspective]] = |
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
772 |
get_blob match { |
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
773 |
case None => |
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
774 |
List( |
65356 | 775 |
Node.Deps( |
66773 | 776 |
if (session.resources.session_base.loaded_theory(node_name)) { |
777 |
node_header.append_errors( |
|
778 |
List("Cannot update finished theory " + quote(node_name.theory))) |
|
779 |
} |
|
64827
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
780 |
else node_header), |
65356 | 781 |
Node.Edits(text_edits), perspective) |
782 |
case Some(blob) => List(Node.Blob(blob), Node.Edits(text_edits)) |
|
64827
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
783 |
} |
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
784 |
edits.flatMap(edit => if (edit.is_void) None else Some(node_name -> edit)) |
4ef1eb75f1cd
uniform Document.Model.node_edits (without void edits);
wenzelm
parents:
64819
diff
changeset
|
785 |
} |
64814 | 786 |
} |
787 |
||
788 |
||
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55801
diff
changeset
|
789 |
/** global state -- document structure, execution process, editing history **/ |
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55801
diff
changeset
|
790 |
|
52563 | 791 |
type Assign_Update = |
792 |
List[(Document_ID.Command, List[Document_ID.Exec])] // update of exec state assignment |
|
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44475
diff
changeset
|
793 |
|
75393 | 794 |
object State { |
38373 | 795 |
class Fail(state: State) extends Exception |
796 |
||
75393 | 797 |
object Assignment { |
46683 | 798 |
val init: Assignment = new Assignment() |
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
799 |
} |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
800 |
|
46712 | 801 |
final class Assignment private( |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
802 |
val command_execs: Map[Document_ID.Command, List[Document_ID.Exec]] = Map.empty, |
75393 | 803 |
val is_finished: Boolean = false |
804 |
) { |
|
67114 | 805 |
override def toString: String = "Assignment(" + command_execs.size + "," + is_finished + ")" |
806 |
||
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73031
diff
changeset
|
807 |
def check_finished: Assignment = { require(is_finished, "assignment not finished"); this } |
47388
fe4b245af74c
discontinued obsolete last_execs (cf. cd3ab7625519);
wenzelm
parents:
46997
diff
changeset
|
808 |
def unfinished: Assignment = new Assignment(command_execs, false) |
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
809 |
|
75393 | 810 |
def assign(update: Assign_Update): Assignment = { |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73031
diff
changeset
|
811 |
require(!is_finished, "assignment already finished") |
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
812 |
val command_execs1 = |
73359 | 813 |
update.foldLeft(command_execs) { |
52563 | 814 |
case (res, (command_id, exec_ids)) => |
815 |
if (exec_ids.isEmpty) res - command_id |
|
816 |
else res + (command_id -> exec_ids) |
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
817 |
} |
47388
fe4b245af74c
discontinued obsolete last_execs (cf. cd3ab7625519);
wenzelm
parents:
46997
diff
changeset
|
818 |
new Assignment(command_execs1, true) |
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
819 |
} |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
820 |
} |
46682 | 821 |
|
822 |
val init: State = |
|
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69633
diff
changeset
|
823 |
State().define_version(Version.init, Assignment.init).assign(Version.init.id, Nil, Nil)._2 |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
824 |
} |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
825 |
|
46712 | 826 |
final case class State private( |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
827 |
/*reachable versions*/ |
60215 | 828 |
versions: Map[Document_ID.Version, Version] = Map.empty, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
829 |
/*inlined auxiliary files*/ |
60215 | 830 |
blobs: Set[SHA1.Digest] = Set.empty, |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
831 |
/*loaded theories in batch builds*/ |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
832 |
theories: Map[Document_ID.Exec, Command.State] = Map.empty, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
833 |
/*static markup from define_command*/ |
60215 | 834 |
commands: Map[Document_ID.Command, Command.State] = Map.empty, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
835 |
/*dynamic markup from execution*/ |
60215 | 836 |
execs: Map[Document_ID.Exec, Command.State] = Map.empty, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
837 |
/*command-exec assignment for each version*/ |
60215 | 838 |
assignments: Map[Document_ID.Version, State.Assignment] = Map.empty, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
839 |
/*commands with markup produced by other commands (imm_succs)*/ |
60215 | 840 |
commands_redirection: Graph[Document_ID.Command, Unit] = Graph.long, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
841 |
/*explicit (linear) history*/ |
60215 | 842 |
history: History = History.init, |
57976
bf99106b6672
postpone changes in intermediate state between remove_versions/removed_versions, which is important for handle_change to refer to defined items on prover side;
wenzelm
parents:
57842
diff
changeset
|
843 |
/*intermediate state between remove_versions/removed_versions*/ |
75393 | 844 |
removing_versions: Boolean = false |
845 |
) { |
|
68496 | 846 |
override def toString: String = |
847 |
"State(versions = " + versions.size + |
|
848 |
", blobs = " + blobs.size + |
|
849 |
", commands = " + commands.size + |
|
850 |
", execs = " + execs.size + |
|
851 |
", assignments = " + assignments.size + |
|
852 |
", commands_redirection = " + commands_redirection.size + |
|
853 |
", history = " + history.undo_list.size + |
|
854 |
", removing_versions = " + removing_versions + ")" |
|
855 |
||
38373 | 856 |
private def fail[A]: A = throw new State.Fail(this) |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
857 |
|
75393 | 858 |
def define_version(version: Version, assignment: State.Assignment): State = { |
38417 | 859 |
val id = version.id |
860 |
copy(versions = versions + (id -> version), |
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
861 |
assignments = assignments + (id -> assignment.unfinished)) |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
862 |
} |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
863 |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
864 |
def define_blob(digest: SHA1.Digest): State = copy(blobs = blobs + digest) |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
865 |
def defined_blob(digest: SHA1.Digest): Boolean = blobs.contains(digest) |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
866 |
|
75393 | 867 |
def define_command(command: Command): State = { |
38373 | 868 |
val id = command.id |
72719 | 869 |
if (commands.isDefinedAt(id)) fail |
870 |
else copy(commands = commands + (id -> command.init_state)) |
|
38373 | 871 |
} |
872 |
||
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
873 |
def defined_command(id: Document_ID.Command): Boolean = commands.isDefinedAt(id) |
44582 | 874 |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
875 |
def the_version(id: Document_ID.Version): Version = versions.getOrElse(id, fail) |
52564
4e855c120f6a
tuned signature -- NB: Command.read is actually part of Command.eval;
wenzelm
parents:
52563
diff
changeset
|
876 |
def the_static_state(id: Document_ID.Command): Command.State = commands.getOrElse(id, fail) |
4e855c120f6a
tuned signature -- NB: Command.read is actually part of Command.eval;
wenzelm
parents:
52563
diff
changeset
|
877 |
def the_dynamic_state(id: Document_ID.Exec): Command.State = execs.getOrElse(id, fail) |
52563 | 878 |
def the_assignment(version: Version): State.Assignment = assignments.getOrElse(version.id, fail) |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
879 |
|
68857 | 880 |
def lookup_id(id: Document_ID.Generic): Option[Command.State] = |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
881 |
theories.get(id) orElse commands.get(id) orElse execs.get(id) |
68857 | 882 |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
883 |
private def self_id(st: Command.State)(id: Document_ID.Generic): Boolean = |
56295
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
56176
diff
changeset
|
884 |
id == st.command.id || |
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
56176
diff
changeset
|
885 |
(execs.get(id) match { case Some(st1) => st1.command.id == st.command.id case None => false }) |
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
56176
diff
changeset
|
886 |
|
75393 | 887 |
private def other_id( |
888 |
node_name: Node.Name, |
|
889 |
id: Document_ID.Generic |
|
890 |
) : Option[(Symbol.Text_Chunk.Id, Symbol.Text_Chunk)] = { |
|
72780 | 891 |
for { |
892 |
st <- lookup_id(id) |
|
893 |
if st.command.node_name == node_name |
|
894 |
} yield (Symbol.Text_Chunk.Id(st.command.id), st.command.chunk) |
|
895 |
} |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
896 |
|
56475 | 897 |
private def redirection(st: Command.State): Graph[Document_ID.Command, Unit] = |
73359 | 898 |
st.markups.redirection_iterator.foldLeft(commands_redirection) { |
899 |
case (graph, id) => |
|
900 |
graph.default_node(id, ()).default_node(st.command.id, ()).add_edge(id, st.command.id) |
|
901 |
} |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
902 |
|
75393 | 903 |
def accumulate( |
904 |
id: Document_ID.Generic, |
|
905 |
message: XML.Elem, |
|
906 |
cache: XML.Cache |
|
907 |
) : (Command.State, State) = { |
|
908 |
def update(st: Command.State): (Command.State, State) = { |
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
72962
diff
changeset
|
909 |
val st1 = st.accumulate(self_id(st), other_id, message, cache) |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
910 |
(st1, copy(commands_redirection = redirection(st1))) |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
911 |
} |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
912 |
execs.get(id).map(update) match { |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
913 |
case Some((st1, state1)) => (st1, state1.copy(execs = execs + (id -> st1))) |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
914 |
case None => |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
915 |
commands.get(id).map(update) match { |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
916 |
case Some((st1, state1)) => (st1, state1.copy(commands = commands + (id -> st1))) |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
917 |
case None => |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
918 |
theories.get(id).map(update) match { |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
919 |
case Some((st1, state1)) => (st1, state1.copy(theories = theories + (id -> st1))) |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
920 |
case None => fail |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
921 |
} |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
922 |
} |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
923 |
} |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
924 |
} |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
925 |
|
75393 | 926 |
def add_export( |
927 |
id: Document_ID.Generic, |
|
928 |
entry: Command.Exports.Entry |
|
929 |
): (Command.State, State) = { |
|
68101 | 930 |
execs.get(id) match { |
931 |
case Some(st) => |
|
68114 | 932 |
st.add_export(entry) match { |
933 |
case Some(new_st) => (new_st, copy(execs = execs + (id -> new_st))) |
|
934 |
case None => fail |
|
935 |
} |
|
68101 | 936 |
case None => |
937 |
commands.get(id) match { |
|
938 |
case Some(st) => |
|
68114 | 939 |
st.add_export(entry) match { |
940 |
case Some(new_st) => (new_st, copy(commands = commands + (id -> new_st))) |
|
941 |
case None => fail |
|
942 |
} |
|
68101 | 943 |
case None => fail |
944 |
} |
|
945 |
} |
|
946 |
} |
|
947 |
||
69633 | 948 |
def node_exports(version: Version, node_name: Node.Name): Command.Exports = |
949 |
Command.Exports.merge( |
|
950 |
for { |
|
951 |
command <- version.nodes(node_name).commands.iterator |
|
952 |
st <- command_states(version, command).iterator |
|
953 |
} yield st.exports) |
|
954 |
||
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
955 |
def begin_theory( |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
956 |
node_name: Node.Name, |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
957 |
id: Document_ID.Exec, |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
958 |
source: String, |
75393 | 959 |
blobs_info: Command.Blobs_Info |
960 |
): State = { |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
961 |
if (theories.isDefinedAt(id)) fail |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
962 |
else { |
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
963 |
val command = |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
964 |
Command.unparsed(source, theory = true, id = id, node_name = node_name, |
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
965 |
blobs_info = blobs_info) |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
966 |
copy(theories = theories + (id -> command.empty_state)) |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
967 |
} |
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
968 |
} |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
969 |
|
72861
3f5e6da08687
clarified protocol: support "isabelle log" on failed theories as well;
wenzelm
parents:
72860
diff
changeset
|
970 |
def end_theory(id: Document_ID.Exec): (Snapshot, State) = |
3f5e6da08687
clarified protocol: support "isabelle log" on failed theories as well;
wenzelm
parents:
72860
diff
changeset
|
971 |
theories.get(id) match { |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
972 |
case None => fail |
72721
79f5e843e5ec
clarified signature: prefer high-level Snapshot over low-level Command.State;
wenzelm
parents:
72719
diff
changeset
|
973 |
case Some(st) => |
79f5e843e5ec
clarified signature: prefer high-level Snapshot over low-level Command.State;
wenzelm
parents:
72719
diff
changeset
|
974 |
val command = st.command |
79f5e843e5ec
clarified signature: prefer high-level Snapshot over low-level Command.State;
wenzelm
parents:
72719
diff
changeset
|
975 |
val node_name = command.node_name |
79f5e843e5ec
clarified signature: prefer high-level Snapshot over low-level Command.State;
wenzelm
parents:
72719
diff
changeset
|
976 |
val command1 = |
72861
3f5e6da08687
clarified protocol: support "isabelle log" on failed theories as well;
wenzelm
parents:
72860
diff
changeset
|
977 |
Command.unparsed(command.source, theory = true, id = id, node_name = node_name, |
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
978 |
blobs_info = command.blobs_info, results = st.results, markups = st.markups) |
72861
3f5e6da08687
clarified protocol: support "isabelle log" on failed theories as well;
wenzelm
parents:
72860
diff
changeset
|
979 |
val state1 = copy(theories = theories - id) |
72958 | 980 |
(state1.snippet(command1), state1) |
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
981 |
} |
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72669
diff
changeset
|
982 |
|
75393 | 983 |
def assign( |
984 |
id: Document_ID.Version, |
|
985 |
edited: List[String], |
|
986 |
update: Assign_Update |
|
987 |
) : ((List[Node.Name], List[Command]), State) = { |
|
38417 | 988 |
val version = the_version(id) |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
989 |
|
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69633
diff
changeset
|
990 |
val edited_set = edited.toSet |
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69633
diff
changeset
|
991 |
val edited_nodes = |
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69633
diff
changeset
|
992 |
(for { (name, _) <- version.nodes.iterator if edited_set(name.node) } yield name).toList |
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69633
diff
changeset
|
993 |
|
52566
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
994 |
def upd(exec_id: Document_ID.Exec, st: Command.State) |
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
995 |
: Option[(Document_ID.Exec, Command.State)] = |
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
996 |
if (execs.isDefinedAt(exec_id)) None else Some(exec_id -> st) |
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
997 |
|
44543 | 998 |
val (changed_commands, new_execs) = |
73361 | 999 |
update.foldLeft((List.empty[Command], execs)) { |
52566
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
1000 |
case ((commands1, execs1), (command_id, exec)) => |
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
1001 |
val st = the_static_state(command_id) |
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
1002 |
val command = st.command |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1003 |
val commands2 = command :: commands1 |
44543 | 1004 |
val execs2 = |
1005 |
exec match { |
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1006 |
case Nil => execs1 |
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1007 |
case eval_id :: print_ids => |
52566
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
1008 |
execs1 ++ upd(eval_id, st) ++ |
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
1009 |
(for (id <- print_ids; up <- upd(id, command.empty_state)) yield up) |
44543 | 1010 |
} |
1011 |
(commands2, execs2) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1012 |
} |
52563 | 1013 |
val new_assignment = the_assignment(version).assign(update) |
43722 | 1014 |
val new_state = copy(assignments = assignments + (id -> new_assignment), execs = new_execs) |
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44475
diff
changeset
|
1015 |
|
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69633
diff
changeset
|
1016 |
((edited_nodes, changed_commands), new_state) |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1017 |
} |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1018 |
|
38417 | 1019 |
def is_assigned(version: Version): Boolean = |
43722 | 1020 |
assignments.get(version.id) match { |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1021 |
case Some(assgn) => assgn.is_finished |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1022 |
case None => false |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1023 |
} |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
1024 |
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
1025 |
def is_stable(change: Change): Boolean = |
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
1026 |
change.is_finished && is_assigned(change.version.get_finished) |
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
1027 |
|
46944
9fc22eb6408c
more recent recent_syntax, e.g. relevant for document rendering during startup;
wenzelm
parents:
46942
diff
changeset
|
1028 |
def recent_finished: Change = history.undo_list.find(_.is_finished) getOrElse fail |
44672 | 1029 |
def recent_stable: Change = history.undo_list.find(is_stable) getOrElse fail |
60933
6d03e05ef041
more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents:
60916
diff
changeset
|
1030 |
def stable_tip_version: Option[Version] = |
6d03e05ef041
more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents:
60916
diff
changeset
|
1031 |
if (is_stable(history.tip)) Some(history.tip.version.get_finished) else None |
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
1032 |
|
44446 | 1033 |
def continue_history( |
56711 | 1034 |
previous: Future[Version], |
1035 |
edits: List[Edit_Text], |
|
75393 | 1036 |
version: Future[Version] |
1037 |
): State = { |
|
46678 | 1038 |
val change = Change.make(previous, edits, version) |
56711 | 1039 |
copy(history = history + change) |
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
1040 |
} |
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
1041 |
|
75393 | 1042 |
def remove_versions(retain: Int = 0): (List[Version], State) = { |
46679 | 1043 |
history.prune(is_stable, retain) match { |
1044 |
case Some((dropped, history1)) => |
|
57976
bf99106b6672
postpone changes in intermediate state between remove_versions/removed_versions, which is important for handle_change to refer to defined items on prover side;
wenzelm
parents:
57842
diff
changeset
|
1045 |
val old_versions = dropped.map(change => change.version.get_finished) |
59319 | 1046 |
val removing = old_versions.nonEmpty |
57976
bf99106b6672
postpone changes in intermediate state between remove_versions/removed_versions, which is important for handle_change to refer to defined items on prover side;
wenzelm
parents:
57842
diff
changeset
|
1047 |
val state1 = copy(history = history1, removing_versions = removing) |
bf99106b6672
postpone changes in intermediate state between remove_versions/removed_versions, which is important for handle_change to refer to defined items on prover side;
wenzelm
parents:
57842
diff
changeset
|
1048 |
(old_versions, state1) |
46679 | 1049 |
case None => fail |
44672 | 1050 |
} |
1051 |
} |
|
1052 |
||
75393 | 1053 |
def removed_versions(removed: List[Document_ID.Version]): State = { |
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
1054 |
val versions1 = Version.purge_suppressed(versions -- removed) |
67110
3156faac30a7
purge hidden nodes more thoroughly: is_hidden may become true only later;
wenzelm
parents:
67014
diff
changeset
|
1055 |
|
44676 | 1056 |
val assignments1 = assignments -- removed |
67112 | 1057 |
var blobs1_names = Set.empty[Node.Name] |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
1058 |
var blobs1 = Set.empty[SHA1.Digest] |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
1059 |
var commands1 = Map.empty[Document_ID.Command, Command.State] |
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
1060 |
var execs1 = Map.empty[Document_ID.Exec, Command.State] |
44676 | 1061 |
for { |
67112 | 1062 |
(version_id, version) <- versions1.iterator |
46997 | 1063 |
command_execs = assignments1(version_id).command_execs |
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56354
diff
changeset
|
1064 |
(_, node) <- version.nodes.iterator |
44676 | 1065 |
command <- node.commands.iterator |
1066 |
} { |
|
67112 | 1067 |
for ((name, digest) <- command.blobs_defined) { |
1068 |
blobs1_names += name |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
1069 |
blobs1 += digest |
67112 | 1070 |
} |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
1071 |
|
52568 | 1072 |
if (!commands1.isDefinedAt(command.id)) |
1073 |
commands.get(command.id).foreach(st => commands1 += (command.id -> st)) |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
1074 |
|
52568 | 1075 |
for (exec_id <- command_execs.getOrElse(command.id, Nil)) { |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1076 |
if (!execs1.isDefinedAt(exec_id)) |
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1077 |
execs.get(exec_id).foreach(st => execs1 += (exec_id -> st)) |
44676 | 1078 |
} |
1079 |
} |
|
67112 | 1080 |
|
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1081 |
copy( |
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
1082 |
versions = versions1, |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1083 |
blobs = blobs1, |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1084 |
commands = commands1, |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1085 |
execs = execs1, |
70699 | 1086 |
commands_redirection = commands_redirection.restrict(commands1.keySet), |
57976
bf99106b6672
postpone changes in intermediate state between remove_versions/removed_versions, which is important for handle_change to refer to defined items on prover side;
wenzelm
parents:
57842
diff
changeset
|
1087 |
assignments = assignments1, |
68300
cd8ab1a7a286
retain isolated blob nodes (amending deb2fcbda16e): avoid failure of Session.handle_change with "Missing blob", when opening theory with load command later;
wenzelm
parents:
68299
diff
changeset
|
1088 |
history = history.purge(versions1), |
57976
bf99106b6672
postpone changes in intermediate state between remove_versions/removed_versions, which is important for handle_change to refer to defined items on prover side;
wenzelm
parents:
57842
diff
changeset
|
1089 |
removing_versions = false) |
44676 | 1090 |
} |
1091 |
||
75393 | 1092 |
def command_id_map( |
1093 |
version: Version, |
|
1094 |
commands: Iterable[Command] |
|
1095 |
) : Map[Document_ID.Generic, Command] = { |
|
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73031
diff
changeset
|
1096 |
require(is_assigned(version), "version not assigned (command_id_map)") |
68836 | 1097 |
val assignment = the_assignment(version).check_finished |
1098 |
(for { |
|
1099 |
command <- commands.iterator |
|
1100 |
id <- (command.id :: assignment.command_execs.getOrElse(command.id, Nil)).iterator |
|
1101 |
} yield (id -> command)).toMap |
|
1102 |
} |
|
1103 |
||
75393 | 1104 |
def command_maybe_consolidated(version: Version, command: Command): Boolean = { |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73031
diff
changeset
|
1105 |
require(is_assigned(version), "version not assigned (command_maybe_consolidated)") |
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1106 |
try { |
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1107 |
the_assignment(version).check_finished.command_execs.getOrElse(command.id, Nil) match { |
70780
034742453594
more robust: avoid update/interrupt of long-running print_consolidation;
wenzelm
parents:
70716
diff
changeset
|
1108 |
case eval_id :: print_ids => |
034742453594
more robust: avoid update/interrupt of long-running print_consolidation;
wenzelm
parents:
70716
diff
changeset
|
1109 |
the_dynamic_state(eval_id).maybe_consolidated && |
034742453594
more robust: avoid update/interrupt of long-running print_consolidation;
wenzelm
parents:
70716
diff
changeset
|
1110 |
!print_ids.exists(print_id => the_dynamic_state(print_id).consolidating) |
034742453594
more robust: avoid update/interrupt of long-running print_consolidation;
wenzelm
parents:
70716
diff
changeset
|
1111 |
case Nil => false |
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1112 |
} |
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1113 |
} |
70780
034742453594
more robust: avoid update/interrupt of long-running print_consolidation;
wenzelm
parents:
70716
diff
changeset
|
1114 |
catch { case _: State.Fail => false } |
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1115 |
} |
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1116 |
|
75393 | 1117 |
private def command_states_self( |
1118 |
version: Version, |
|
1119 |
command: Command |
|
1120 |
) : List[(Document_ID.Generic, Command.State)] = { |
|
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73031
diff
changeset
|
1121 |
require(is_assigned(version), "version not assigned (command_states_self)") |
44613 | 1122 |
try { |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1123 |
the_assignment(version).check_finished.command_execs.getOrElse(command.id, Nil) |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1124 |
.map(id => id -> the_dynamic_state(id)) match { |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1125 |
case Nil => fail |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1126 |
case res => res |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
1127 |
} |
44613 | 1128 |
} |
47395
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
1129 |
catch { |
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
1130 |
case _: State.Fail => |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1131 |
try { List(command.id -> the_static_state(command.id)) } |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1132 |
catch { case _: State.Fail => List(command.id -> command.init_state) } |
47395
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
1133 |
} |
44613 | 1134 |
} |
1135 |
||
75393 | 1136 |
def command_states(version: Version, command: Command): List[Command.State] = { |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1137 |
val self = command_states_self(version, command) |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1138 |
val others = |
56475 | 1139 |
if (commands_redirection.defined(command.id)) { |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1140 |
(for { |
56475 | 1141 |
command_id <- commands_redirection.imm_succs(command.id).iterator |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1142 |
(id, st) <- command_states_self(version, the_static_state(command_id).command) |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1143 |
if !self.exists(_._1 == id) |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1144 |
} yield (id, st)).toMap.valuesIterator.toList |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1145 |
} |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1146 |
else Nil |
56489 | 1147 |
self.map(_._2) ::: others.flatMap(_.redirect(command)) |
56470
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1148 |
} |
8eda56033203
accumulate markup reports for "other" command ids, which are later retargeted and merged for rendering (in erratic order);
wenzelm
parents:
56468
diff
changeset
|
1149 |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
1150 |
def command_results(version: Version, command: Command): Command.Results = |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
1151 |
Command.State.merge_results(command_states(version, command)) |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
1152 |
|
56301
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56300
diff
changeset
|
1153 |
def command_markup(version: Version, command: Command, index: Command.Markup_Index, |
56743 | 1154 |
range: Text.Range, elements: Markup.Elements): Markup_Tree = |
56301
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56300
diff
changeset
|
1155 |
Command.State.merge_markup(command_states(version, command), index, range, elements) |
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
1156 |
|
72723 | 1157 |
def xml_markup( |
66041 | 1158 |
version: Version, |
67264 | 1159 |
node_name: Node.Name, |
72723 | 1160 |
range: Text.Range = Text.Range.full, |
75393 | 1161 |
elements: Markup.Elements = Markup.Elements.full |
1162 |
): XML.Body = { |
|
67264 | 1163 |
val node = version.nodes(node_name) |
1164 |
if (node_name.is_theory) { |
|
1165 |
val markup_index = Command.Markup_Index.markup |
|
1166 |
(for { |
|
1167 |
command <- node.commands.iterator |
|
1168 |
command_range <- command.range.try_restrict(range).iterator |
|
1169 |
markup = command_markup(version, command, markup_index, command_range, elements) |
|
1170 |
tree <- markup.to_XML(command_range, command.source, elements).iterator |
|
1171 |
} yield tree).toList |
|
1172 |
} |
|
1173 |
else { |
|
67265
f32287c95432
store full blob source for the sake of markup_to_XML;
wenzelm
parents:
67264
diff
changeset
|
1174 |
val node_source = node.source |
67264 | 1175 |
Text.Range(0, node_source.length).try_restrict(range) match { |
1176 |
case None => Nil |
|
1177 |
case Some(node_range) => |
|
1178 |
val markup = |
|
1179 |
version.nodes.commands_loading(node_name).headOption match { |
|
1180 |
case None => Markup_Tree.empty |
|
1181 |
case Some(command) => |
|
1182 |
val chunk_name = Symbol.Text_Chunk.File(node_name.node) |
|
1183 |
val markup_index = Command.Markup_Index(false, chunk_name) |
|
1184 |
command_markup(version, command, markup_index, node_range, elements) |
|
1185 |
} |
|
1186 |
markup.to_XML(node_range, node_source, elements) |
|
1187 |
} |
|
1188 |
} |
|
66041 | 1189 |
} |
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
1190 |
|
68323 | 1191 |
def node_initialized(version: Version, name: Node.Name): Boolean = |
1192 |
name.is_theory && |
|
1193 |
(version.nodes(name).commands.iterator.find(_.potentially_initialized) match { |
|
1194 |
case None => false |
|
1195 |
case Some(command) => command_states(version, command).headOption.exists(_.initialized) |
|
1196 |
}) |
|
1197 |
||
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1198 |
def node_maybe_consolidated(version: Version, name: Node.Name): Boolean = |
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1199 |
name.is_theory && |
70780
034742453594
more robust: avoid update/interrupt of long-running print_consolidation;
wenzelm
parents:
70716
diff
changeset
|
1200 |
version.nodes(name).commands.reverse.iterator.forall(command_maybe_consolidated(version, _)) |
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68365
diff
changeset
|
1201 |
|
66379
6392766f3c25
maintain "consolidated" status of theory nodes, which means all evals are finished (but not necessarily prints nor imports);
wenzelm
parents:
66195
diff
changeset
|
1202 |
def node_consolidated(version: Version, name: Node.Name): Boolean = |
75393 | 1203 |
!name.is_theory || { |
68335 | 1204 |
val it = version.nodes(name).commands.reverse.iterator |
73344 | 1205 |
it.hasNext && command_states(version, it.next()).exists(_.consolidated) |
68335 | 1206 |
} |
66379
6392766f3c25
maintain "consolidated" status of theory nodes, which means all evals are finished (but not necessarily prints nor imports);
wenzelm
parents:
66195
diff
changeset
|
1207 |
|
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
1208 |
def snapshot( |
72818 | 1209 |
node_name: Node.Name = Node.Name.empty, |
72816
ea4f86914cb2
support for PIDE markup for auxiliary files ("blobs");
wenzelm
parents:
72780
diff
changeset
|
1210 |
pending_edits: List[Text.Edit] = Nil, |
75393 | 1211 |
snippet_command: Option[Command] = None |
1212 |
): Snapshot = { |
|
72819 | 1213 |
val stable = recent_stable |
72820 | 1214 |
val version = stable.version.get_finished |
57620
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
1215 |
|
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
1216 |
val rev_pending_changes = |
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
1217 |
for { |
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
1218 |
change <- history.undo_list.takeWhile(_ != stable) |
72818 | 1219 |
(name, edits) <- change.rev_edits |
1220 |
if name == node_name |
|
57620
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
1221 |
} yield edits |
c30ab960875e
more explicit treatment of cleared nodes (removal is implicit);
wenzelm
parents:
57619
diff
changeset
|
1222 |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
1223 |
val edits = |
73359 | 1224 |
rev_pending_changes.foldLeft(pending_edits) { |
64819 | 1225 |
case (edits, Node.Edits(es)) => es ::: edits |
1226 |
case (edits, _) => edits |
|
73359 | 1227 |
} |
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
1228 |
|
72820 | 1229 |
new Snapshot(this, version, node_name, edits, snippet_command) |
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
1230 |
} |
72859 | 1231 |
|
72958 | 1232 |
def snippet(command: Command): Snapshot = |
1233 |
snapshot().snippet(command) |
|
34485 | 1234 |
} |
34840
6c5560d48561
more precise treatment of document/state assigment;
wenzelm
parents:
34838
diff
changeset
|
1235 |
} |