| author | haftmann | 
| Sun, 26 Jan 2014 16:23:47 +0100 | |
| changeset 55154 | 2733a57d100f | 
| parent 55134 | 1b67b17cdad5 | 
| child 55431 | e0f20a44ff9d | 
| permissions | -rw-r--r-- | 
| 34268 | 1 | /* Title: Pure/Thy/thy_syntax.scala | 
| 2 | Author: Makarius | |
| 3 | ||
| 38374 | 4 | Superficial theory syntax: tokens and spans. | 
| 34268 | 5 | */ | 
| 6 | ||
| 7 | package isabelle | |
| 8 | ||
| 9 | ||
| 38239 
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
 wenzelm parents: 
36956diff
changeset | 10 | import scala.collection.mutable | 
| 38374 | 11 | import scala.annotation.tailrec | 
| 38239 
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
 wenzelm parents: 
36956diff
changeset | 12 | |
| 
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
 wenzelm parents: 
36956diff
changeset | 13 | |
| 34303 | 14 | object Thy_Syntax | 
| 34268 | 15 | {
 | 
| 40454 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 16 | /** nested structure **/ | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 17 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 18 | object Structure | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 19 |   {
 | 
| 40478 
4bae781b8f7c
replaced Document.Node_Text_Edit by Document.Text_Edit, with treatment of deleted nodes;
 wenzelm parents: 
40457diff
changeset | 20 |     sealed abstract class Entry { def length: Int }
 | 
| 40454 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 21 | case class Block(val name: String, val body: List[Entry]) extends Entry | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 22 |     {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 23 | val length: Int = (0 /: body)(_ + _.length) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 24 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 25 | case class Atom(val command: Command) extends Entry | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 26 |     {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 27 | def length: Int = command.length | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 28 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 29 | |
| 46811 
03a2dc9e0624
clarified command span: include trailing whitespace/comments and thus reduce number of ignored spans with associated transactions and states (factor 2);
 wenzelm parents: 
46749diff
changeset | 30 | def parse(syntax: Outer_Syntax, node_name: Document.Node.Name, text: CharSequence): Entry = | 
| 40454 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 31 |     {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 32 | /* stack operations */ | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 33 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 34 | def buffer(): mutable.ListBuffer[Entry] = new mutable.ListBuffer[Entry] | 
| 44615 | 35 | var stack: List[(Int, String, mutable.ListBuffer[Entry])] = | 
| 54515 | 36 | List((0, node_name.toString, buffer())) | 
| 40454 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 37 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 38 | @tailrec def close(level: Int => Boolean) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 39 |       {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 40 |         stack match {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 41 | case (lev, name, body) :: (_, _, body2) :: rest if level(lev) => | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 42 | body2 += Block(name, body.toList) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 43 | stack = stack.tail | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 44 | close(level) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 45 | case _ => | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 46 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 47 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 48 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 49 | def result(): Entry = | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 50 |       {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 51 | close(_ => true) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 52 | val (_, name, body) = stack.head | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 53 | Block(name, body.toList) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 54 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 55 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 56 | def add(command: Command) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 57 |       {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 58 |         syntax.heading_level(command) match {
 | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 59 | case Some(i) => | 
| 46969 | 60 | close(_ > i) | 
| 61 | stack = (i + 1, command.source, buffer()) :: stack | |
| 40454 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 62 | case None => | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 63 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 64 | stack.head._3 += Atom(command) | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 65 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 66 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 67 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 68 | /* result structure */ | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 69 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 70 | val spans = parse_spans(syntax.scan(text)) | 
| 54519 
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
 wenzelm parents: 
54518diff
changeset | 71 | spans.foreach(span => add(Command(Document_ID.none, node_name, Nil, span))) | 
| 40454 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 72 | result() | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 73 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 74 | } | 
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 75 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 76 | |
| 
2516ea25a54b
some support for nested source structure, based on section headings;
 wenzelm parents: 
38878diff
changeset | 77 | |
| 38374 | 78 | /** parse spans **/ | 
| 79 | ||
| 52535 
b7badd371e4d
tuned signature -- eliminated pointless type synonym;
 wenzelm parents: 
52530diff
changeset | 80 | def parse_spans(toks: List[Token]): List[List[Token]] = | 
| 34268 | 81 |   {
 | 
| 52535 
b7badd371e4d
tuned signature -- eliminated pointless type synonym;
 wenzelm parents: 
52530diff
changeset | 82 | val result = new mutable.ListBuffer[List[Token]] | 
| 38239 
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
 wenzelm parents: 
36956diff
changeset | 83 | val span = new mutable.ListBuffer[Token] | 
| 53843 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 84 | val improper = new mutable.ListBuffer[Token] | 
| 34268 | 85 | |
| 53843 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 86 | def flush() | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 87 |     {
 | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 88 |       if (!span.isEmpty) { result += span.toList; span.clear }
 | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 89 |       if (!improper.isEmpty) { result += improper.toList; improper.clear }
 | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 90 | } | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 91 |     for (tok <- toks) {
 | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 92 |       if (tok.is_command) { flush(); span += tok }
 | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 93 | else if (tok.is_improper) improper += tok | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 94 |       else { span ++= improper; improper.clear; span += tok }
 | 
| 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 95 | } | 
| 46811 
03a2dc9e0624
clarified command span: include trailing whitespace/comments and thus reduce number of ignored spans with associated transactions and states (factor 2);
 wenzelm parents: 
46749diff
changeset | 96 | flush() | 
| 53843 
88c6e630c15f
clarified command spans (again, see also 03a2dc9e0624): restrict to proper range to allow Isabelle.command_edit adding material monotonically without destroying the command (e.g. relevant for sendback from sledgehammer);
 wenzelm parents: 
52901diff
changeset | 97 | |
| 38239 
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
 wenzelm parents: 
36956diff
changeset | 98 | result.toList | 
| 34268 | 99 | } | 
| 38374 | 100 | |
| 101 | ||
| 102 | ||
| 44436 
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
 wenzelm parents: 
44388diff
changeset | 103 | /** perspective **/ | 
| 44388 | 104 | |
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 105 | def command_perspective( | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 106 | node: Document.Node, | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 107 | perspective: Text.Perspective, | 
| 52887 | 108 | overlays: Document.Node.Overlays): (Command.Perspective, Command.Perspective) = | 
| 44388 | 109 |   {
 | 
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 110 | if (perspective.is_empty && overlays.is_empty) | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 111 | (Command.Perspective.empty, Command.Perspective.empty) | 
| 44388 | 112 |     else {
 | 
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 113 | val has_overlay = overlays.commands | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 114 | val visible = new mutable.ListBuffer[Command] | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 115 | val visible_overlay = new mutable.ListBuffer[Command] | 
| 44388 | 116 | @tailrec | 
| 117 | def check_ranges(ranges: List[Text.Range], commands: Stream[(Command, Text.Offset)]) | |
| 118 |       {
 | |
| 119 |         (ranges, commands) match {
 | |
| 120 | case (range :: more_ranges, (command, offset) #:: more_commands) => | |
| 121 | val command_range = command.range + offset | |
| 122 |             range compare command_range match {
 | |
| 123 | case 0 => | |
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 124 | visible += command | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 125 | visible_overlay += command | 
| 44388 | 126 | check_ranges(ranges, more_commands) | 
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 127 | case c => | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 128 | if (has_overlay(command)) visible_overlay += command | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 129 | |
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 130 | if (c < 0) check_ranges(more_ranges, commands) | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 131 | else check_ranges(ranges, more_commands) | 
| 44388 | 132 | } | 
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 133 | |
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 134 | case (Nil, (command, _) #:: more_commands) => | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 135 | if (has_overlay(command)) visible_overlay += command | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 136 | |
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 137 | check_ranges(Nil, more_commands) | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 138 | |
| 44388 | 139 | case _ => | 
| 140 | } | |
| 141 | } | |
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 142 | |
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 143 | val commands = | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 144 | if (overlays.is_empty) node.command_range(perspective.range) | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 145 | else node.command_range() | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 146 | check_ranges(perspective.ranges, commands.toStream) | 
| 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 147 | (Command.Perspective(visible.toList), Command.Perspective(visible_overlay.toList)) | 
| 44388 | 148 | } | 
| 149 | } | |
| 150 | ||
| 151 | ||
| 152 | ||
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 153 | /** header edits: structure and outer syntax **/ | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 154 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 155 | private def header_edits( | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 156 | base_syntax: Outer_Syntax, | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 157 | previous: Document.Version, | 
| 55134 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 158 | edits: List[Document.Edit_Text]): | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 159 | ((Outer_Syntax, Boolean), List[Document.Node.Name], Document.Nodes, List[Document.Edit_Command]) = | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 160 |   {
 | 
| 47987 
4e9df6ffcc6e
reparse descendants after update of imports, e.g. required for 'primrec' (line 17 of "src/HOL/Power.thy");
 wenzelm parents: 
47346diff
changeset | 161 | var updated_imports = false | 
| 
4e9df6ffcc6e
reparse descendants after update of imports, e.g. required for 'primrec' (line 17 of "src/HOL/Power.thy");
 wenzelm parents: 
47346diff
changeset | 162 | var updated_keywords = false | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 163 | var nodes = previous.nodes | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 164 | val doc_edits = new mutable.ListBuffer[Document.Edit_Command] | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 165 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 166 |     edits foreach {
 | 
| 48707 
ba531af91148
simplified Document.Node.Header -- internalized errors;
 wenzelm parents: 
48706diff
changeset | 167 | case (name, Document.Node.Deps(header)) => | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 168 | val node = nodes(name) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 169 | val update_header = | 
| 48707 
ba531af91148
simplified Document.Node.Header -- internalized errors;
 wenzelm parents: 
48706diff
changeset | 170 | !node.header.errors.isEmpty || !header.errors.isEmpty || node.header != header | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 171 |         if (update_header) {
 | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 172 | val node1 = node.update_header(header) | 
| 48707 
ba531af91148
simplified Document.Node.Header -- internalized errors;
 wenzelm parents: 
48706diff
changeset | 173 | updated_imports = updated_imports || (node.header.imports != node1.header.imports) | 
| 
ba531af91148
simplified Document.Node.Header -- internalized errors;
 wenzelm parents: 
48706diff
changeset | 174 | updated_keywords = updated_keywords || (node.header.keywords != node1.header.keywords) | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 175 | nodes += (name -> node1) | 
| 48707 
ba531af91148
simplified Document.Node.Header -- internalized errors;
 wenzelm parents: 
48706diff
changeset | 176 | doc_edits += (name -> Document.Node.Deps(header)) | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 177 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 178 | case _ => | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 179 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 180 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 181 | val syntax = | 
| 55134 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 182 |       if (previous.is_init || updated_keywords) {
 | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 183 | val syntax = | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 184 |           (base_syntax /: nodes.entries) {
 | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 185 | case (syn, (_, node)) => syn.add_keywords(node.header.keywords) | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 186 | } | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 187 | (syntax, true) | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 188 | } | 
| 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 189 | else (previous.syntax, false) | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 190 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 191 | val reparse = | 
| 47987 
4e9df6ffcc6e
reparse descendants after update of imports, e.g. required for 'primrec' (line 17 of "src/HOL/Power.thy");
 wenzelm parents: 
47346diff
changeset | 192 | if (updated_imports || updated_keywords) | 
| 
4e9df6ffcc6e
reparse descendants after update of imports, e.g. required for 'primrec' (line 17 of "src/HOL/Power.thy");
 wenzelm parents: 
47346diff
changeset | 193 | nodes.descendants(doc_edits.iterator.map(_._1).toList) | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 194 | else Nil | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 195 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 196 | (syntax, reparse, nodes, doc_edits.toList) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 197 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 198 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 199 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 200 | |
| 38374 | 201 | /** text edits **/ | 
| 202 | ||
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 203 | /* edit individual command source */ | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 204 | |
| 50761 | 205 | @tailrec def edit_text(eds: List[Text.Edit], commands: Linear_Set[Command]): Linear_Set[Command] = | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 206 |   {
 | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 207 |     eds match {
 | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 208 | case e :: es => | 
| 52901 
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
 wenzelm parents: 
52887diff
changeset | 209 |         Document.Node.Commands.starts(commands.iterator).find {
 | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 210 | case (cmd, cmd_start) => | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 211 | e.can_edit(cmd.source, cmd_start) || | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 212 | e.is_insert && e.start == cmd_start + cmd.length | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 213 |         } match {
 | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 214 | case Some((cmd, cmd_start)) if e.can_edit(cmd.source, cmd_start) => | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 215 | val (rest, text) = e.edit(cmd.source, cmd_start) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 216 | val new_commands = commands.insert_after(Some(cmd), Command.unparsed(text)) - cmd | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 217 | edit_text(rest.toList ::: es, new_commands) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 218 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 219 | case Some((cmd, cmd_start)) => | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 220 | edit_text(es, commands.insert_after(Some(cmd), Command.unparsed(e.text))) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 221 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 222 | case None => | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 223 | require(e.is_insert && e.start == 0) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 224 | edit_text(es, commands.insert_after(None, Command.unparsed(e.text))) | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 225 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 226 | case Nil => commands | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 227 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 228 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 229 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 230 | |
| 54513 | 231 | /* inlined files */ | 
| 232 | ||
| 233 | private def find_file(tokens: List[Token]): Option[String] = | |
| 234 |   {
 | |
| 235 | def clean(toks: List[Token]): List[Token] = | |
| 236 |       toks match {
 | |
| 237 | case t :: _ :: ts if t.is_keyword && (t.source == "%" || t.source == "--") => clean(ts) | |
| 238 | case t :: ts => t :: clean(ts) | |
| 239 | case Nil => Nil | |
| 240 | } | |
| 55118 
7df949045dc5
clarified approximative syntax of thy_load commands: first name after command keyword, after cleaning wrt. tags and cmts;
 wenzelm parents: 
54562diff
changeset | 241 |     clean(tokens.filter(_.is_proper)) match {
 | 
| 
7df949045dc5
clarified approximative syntax of thy_load commands: first name after command keyword, after cleaning wrt. tags and cmts;
 wenzelm parents: 
54562diff
changeset | 242 | case tok :: toks if tok.is_command => toks.find(_.is_name).map(_.content) | 
| 
7df949045dc5
clarified approximative syntax of thy_load commands: first name after command keyword, after cleaning wrt. tags and cmts;
 wenzelm parents: 
54562diff
changeset | 243 | case _ => None | 
| 
7df949045dc5
clarified approximative syntax of thy_load commands: first name after command keyword, after cleaning wrt. tags and cmts;
 wenzelm parents: 
54562diff
changeset | 244 | } | 
| 54513 | 245 | } | 
| 246 | ||
| 247 | def span_files(syntax: Outer_Syntax, span: List[Token]): List[String] = | |
| 248 |     syntax.thy_load(span) match {
 | |
| 249 | case Some(exts) => | |
| 250 |         find_file(span) match {
 | |
| 251 | case Some(file) => | |
| 252 | if (exts.isEmpty) List(file) | |
| 253 | else exts.map(ext => file + "." + ext) | |
| 254 | case None => Nil | |
| 255 | } | |
| 256 | case None => Nil | |
| 257 | } | |
| 258 | ||
| 259 | def resolve_files( | |
| 54517 | 260 | thy_load: Thy_Load, | 
| 54513 | 261 | syntax: Outer_Syntax, | 
| 54517 | 262 | node_name: Document.Node.Name, | 
| 263 | span: List[Token], | |
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 264 | doc_blobs: Document.Blobs) | 
| 54519 
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
 wenzelm parents: 
54518diff
changeset | 265 | : List[Command.Blob] = | 
| 54513 | 266 |   {
 | 
| 54517 | 267 | span_files(syntax, span).map(file => | 
| 268 |       Exn.capture {
 | |
| 269 | val name = | |
| 270 | Document.Node.Name(thy_load.append(node_name.master_dir, Path.explode(file))) | |
| 54524 | 271 | (name, doc_blobs.get(name).map(_.sha1_digest)) | 
| 54517 | 272 | } | 
| 273 | ) | |
| 54513 | 274 | } | 
| 275 | ||
| 276 | ||
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 277 | /* reparse range of command spans */ | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 278 | |
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 279 | @tailrec private def chop_common( | 
| 54519 
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
 wenzelm parents: 
54518diff
changeset | 280 | cmds: List[Command], spans: List[(List[Command.Blob], List[Token])]) | 
| 
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
 wenzelm parents: 
54518diff
changeset | 281 | : (List[Command], List[(List[Command.Blob], List[Token])]) = | 
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 282 |     (cmds, spans) match {
 | 
| 54519 
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
 wenzelm parents: 
54518diff
changeset | 283 | case (c :: cs, (blobs, span) :: ps) if c.blobs == blobs && c.span == span => | 
| 54513 | 284 | chop_common(cs, ps) | 
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 285 | case _ => (cmds, spans) | 
| 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 286 | } | 
| 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 287 | |
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 288 | private def reparse_spans( | 
| 54517 | 289 | thy_load: Thy_Load, | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 290 | syntax: Outer_Syntax, | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 291 | doc_blobs: Document.Blobs, | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 292 | name: Document.Node.Name, | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 293 | commands: Linear_Set[Command], | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 294 | first: Command, last: Command): Linear_Set[Command] = | 
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 295 |   {
 | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 296 | val cmds0 = commands.iterator(first, last).toList | 
| 54513 | 297 | val spans0 = | 
| 298 | parse_spans(syntax.scan(cmds0.iterator.map(_.source).mkString)). | |
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 299 | map(span => (resolve_files(thy_load, syntax, name, span, doc_blobs), span)) | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 300 | |
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 301 | val (cmds1, spans1) = chop_common(cmds0, spans0) | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 302 | |
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 303 | val (rev_cmds2, rev_spans2) = chop_common(cmds1.reverse, spans1.reverse) | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 304 | val cmds2 = rev_cmds2.reverse | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 305 | val spans2 = rev_spans2.reverse | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 306 | |
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 307 |     cmds2 match {
 | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 308 | case Nil => | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 309 | assert(spans2.isEmpty) | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 310 | commands | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 311 | case cmd :: _ => | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 312 | val hook = commands.prev(cmd) | 
| 54462 | 313 | val inserted = | 
| 54519 
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
 wenzelm parents: 
54518diff
changeset | 314 |           spans2.map({ case (blobs, span) => Command(Document_ID.make(), name, blobs, span) })
 | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 315 | (commands /: cmds2)(_ - _).append_after(hook, inserted) | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 316 | } | 
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 317 | } | 
| 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 318 | |
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 319 | |
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 320 | /* recover command spans after edits */ | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 321 | |
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 322 | // FIXME somewhat slow | 
| 48746 
9e1b2aafbc7f
more direct Linear_Set.reverse, swapping orientation of the graph;
 wenzelm parents: 
48718diff
changeset | 323 | private def recover_spans( | 
| 54517 | 324 | thy_load: Thy_Load, | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 325 | syntax: Outer_Syntax, | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 326 | doc_blobs: Document.Blobs, | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 327 | name: Document.Node.Name, | 
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 328 | perspective: Command.Perspective, | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 329 | commands: Linear_Set[Command]): Linear_Set[Command] = | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 330 |   {
 | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 331 | val visible = perspective.commands.toSet | 
| 48748 
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
 wenzelm parents: 
48747diff
changeset | 332 | |
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 333 | def next_invisible_command(cmds: Linear_Set[Command], from: Command): Command = | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 334 | cmds.iterator(from).dropWhile(cmd => !cmd.is_command || visible(cmd)) | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 335 | .find(_.is_command) getOrElse cmds.last | 
| 48746 
9e1b2aafbc7f
more direct Linear_Set.reverse, swapping orientation of the graph;
 wenzelm parents: 
48718diff
changeset | 336 | |
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 337 | @tailrec def recover(cmds: Linear_Set[Command]): Linear_Set[Command] = | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 338 |       cmds.find(_.is_unparsed) match {
 | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 339 | case Some(first_unparsed) => | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 340 | val first = next_invisible_command(cmds.reverse, first_unparsed) | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 341 | val last = next_invisible_command(cmds, first_unparsed) | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 342 | recover(reparse_spans(thy_load, syntax, doc_blobs, name, cmds, first, last)) | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 343 | case None => cmds | 
| 48746 
9e1b2aafbc7f
more direct Linear_Set.reverse, swapping orientation of the graph;
 wenzelm parents: 
48718diff
changeset | 344 | } | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 345 | recover(commands) | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 346 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 347 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 348 | |
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 349 | /* consolidate unfinished spans */ | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 350 | |
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 351 | private def consolidate_spans( | 
| 54517 | 352 | thy_load: Thy_Load, | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 353 | syntax: Outer_Syntax, | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 354 | doc_blobs: Document.Blobs, | 
| 49524 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 355 | reparse_limit: Int, | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 356 | name: Document.Node.Name, | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 357 | perspective: Command.Perspective, | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 358 | commands: Linear_Set[Command]): Linear_Set[Command] = | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 359 |   {
 | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 360 | if (perspective.commands.isEmpty) commands | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 361 |     else {
 | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 362 |       commands.find(_.is_unfinished) match {
 | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 363 | case Some(first_unfinished) => | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 364 | val visible = perspective.commands.toSet | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 365 |           commands.reverse.find(visible) match {
 | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 366 | case Some(last_visible) => | 
| 49524 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 367 | val it = commands.iterator(last_visible) | 
| 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 368 | var last = last_visible | 
| 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 369 | var i = 0 | 
| 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 370 |               while (i < reparse_limit && it.hasNext) {
 | 
| 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 371 | last = it.next | 
| 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 372 | i += last.length | 
| 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 373 | } | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 374 | reparse_spans(thy_load, syntax, doc_blobs, name, commands, first_unfinished, last) | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 375 | case None => commands | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 376 | } | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 377 | case None => commands | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 378 | } | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 379 | } | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 380 | } | 
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 381 | |
| 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 382 | |
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 383 | /* main */ | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 384 | |
| 50761 | 385 | def diff_commands(old_cmds: Linear_Set[Command], new_cmds: Linear_Set[Command]) | 
| 52849 | 386 | : List[Command.Edit] = | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 387 |   {
 | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 388 | val removed = old_cmds.iterator.filter(!new_cmds.contains(_)).toList | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 389 | val inserted = new_cmds.iterator.filter(!old_cmds.contains(_)).toList | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 390 | |
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 391 | removed.reverse.map(cmd => (old_cmds.prev(cmd), None)) ::: | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 392 | inserted.map(cmd => (new_cmds.prev(cmd), Some(cmd))) | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 393 | } | 
| 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 394 | |
| 54513 | 395 | private def text_edit( | 
| 54517 | 396 | thy_load: Thy_Load, | 
| 54513 | 397 | syntax: Outer_Syntax, | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 398 | doc_blobs: Document.Blobs, | 
| 54513 | 399 | reparse_limit: Int, | 
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 400 | node: Document.Node, edit: Document.Edit_Text): Document.Node = | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 401 |   {
 | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 402 |     edit match {
 | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 403 | case (_, Document.Node.Clear()) => node.clear | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 404 | |
| 54562 
301a721af68b
clarified node edits sent to prover -- Clear/Blob only required for text edits within editor;
 wenzelm parents: 
54524diff
changeset | 405 | case (_, Document.Node.Blob()) => node | 
| 
301a721af68b
clarified node edits sent to prover -- Clear/Blob only required for text edits within editor;
 wenzelm parents: 
54524diff
changeset | 406 | |
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 407 | case (name, Document.Node.Edits(text_edits)) => | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 408 | val commands0 = node.commands | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 409 | val commands1 = edit_text(text_edits, commands0) | 
| 54517 | 410 | val commands2 = | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 411 | recover_spans(thy_load, syntax, doc_blobs, name, node.perspective.visible, commands1) | 
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 412 | node.update_commands(commands2) | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 413 | |
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 414 | case (_, Document.Node.Deps(_)) => node | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 415 | |
| 52849 | 416 | case (name, Document.Node.Perspective(required, text_perspective, overlays)) => | 
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 417 | val (visible, visible_overlay) = command_perspective(node, text_perspective, overlays) | 
| 52849 | 418 | val perspective: Document.Node.Perspective_Command = | 
| 52861 
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
 wenzelm parents: 
52849diff
changeset | 419 | Document.Node.Perspective(required, visible_overlay, overlays) | 
| 52808 
143f225e50f5
allow explicit indication of required node: full eval, no prints;
 wenzelm parents: 
52535diff
changeset | 420 | if (node.same_perspective(perspective)) node | 
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 421 | else | 
| 49524 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 422 | node.update_perspective(perspective).update_commands( | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 423 | consolidate_spans(thy_load, syntax, doc_blobs, reparse_limit, | 
| 54517 | 424 | name, visible, node.commands)) | 
| 48755 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 425 | } | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 426 | } | 
| 
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
 wenzelm parents: 
48754diff
changeset | 427 | |
| 43722 | 428 | def text_edits( | 
| 54517 | 429 | thy_load: Thy_Load, | 
| 49524 
68796a77c42b
Thy_Syntax.consolidate_spans is subject to editor_reparse_limit, for improved experience of unbalanced comments etc.;
 wenzelm parents: 
49414diff
changeset | 430 | reparse_limit: Int, | 
| 43722 | 431 | previous: Document.Version, | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 432 | doc_blobs: Document.Blobs, | 
| 44157 
a21d3e1e64fd
uniform treatment of header edits as document edits;
 wenzelm parents: 
44156diff
changeset | 433 | edits: List[Document.Edit_Text]) | 
| 55134 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 434 | : (Boolean, List[Document.Edit_Command], Document.Version) = | 
| 38374 | 435 |   {
 | 
| 55134 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 436 | val ((syntax, syntax_changed), reparse0, nodes0, doc_edits0) = | 
| 54517 | 437 | header_edits(thy_load.base_syntax, previous, edits) | 
| 54518 
81a9a54c57fc
always reparse nodes with thy_load commands, to update inlined files;
 wenzelm parents: 
54517diff
changeset | 438 | |
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 439 | if (edits.isEmpty) | 
| 55134 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 440 | (false, Nil, Document.Version.make(syntax, previous.nodes)) | 
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 441 |     else {
 | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 442 | val reparse = | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 443 |         (reparse0 /: nodes0.entries)({
 | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 444 | case (reparse, (name, node)) => | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 445 | if (node.thy_load_commands.isEmpty) reparse | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 446 | else name :: reparse | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 447 | }) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 448 | val reparse_set = reparse.toSet | 
| 46946 
acc8ebf980ca
more explicit header_edits before main text_edits;
 wenzelm parents: 
46942diff
changeset | 449 | |
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 450 | var nodes = nodes0 | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 451 | val doc_edits = new mutable.ListBuffer[Document.Edit_Command]; doc_edits ++= doc_edits0 | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 452 | |
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 453 | val node_edits = | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 454 | (edits ::: reparse.map((_, Document.Node.Edits(Nil)))).groupBy(_._1) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 455 | .asInstanceOf[Map[Document.Node.Name, List[Document.Edit_Text]]] // FIXME ??? | 
| 38374 | 456 | |
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 457 |       node_edits foreach {
 | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 458 | case (name, edits) => | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 459 | val node = nodes(name) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 460 | val commands = node.commands | 
| 48754 
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
 wenzelm parents: 
48748diff
changeset | 461 | |
| 54521 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 462 | val node1 = | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 463 | if (reparse_set(name) && !commands.isEmpty) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 464 | node.update_commands( | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 465 | reparse_spans(thy_load, syntax, doc_blobs, | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 466 | name, commands, commands.head, commands.last)) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 467 | else node | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 468 | val node2 = (node1 /: edits)(text_edit(thy_load, syntax, doc_blobs, reparse_limit, _, _)) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 469 | |
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 470 | if (!(node.same_perspective(node2.perspective))) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 471 | doc_edits += (name -> node2.perspective) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 472 | |
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 473 | doc_edits += (name -> Document.Node.Edits(diff_commands(commands, node2.commands))) | 
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 474 | |
| 
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
 wenzelm parents: 
54519diff
changeset | 475 | nodes += (name -> node2) | 
| 54513 | 476 | } | 
| 477 | ||
| 55134 
1b67b17cdad5
propagate update of outer syntax keywords: global propertiesChanged, buffer TokenMarker.markTokens, text area repainting;
 wenzelm parents: 
55118diff
changeset | 478 | (syntax_changed, doc_edits.toList, Document.Version.make(syntax, nodes)) | 
| 38374 | 479 | } | 
| 480 | } | |
| 34268 | 481 | } |