author | haftmann |
Fri, 01 Aug 2025 20:01:55 +0200 | |
changeset 82912 | ad66fb23998a |
parent 82798 | 16e2ce15df90 |
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:
36956
diff
changeset
|
10 |
import scala.collection.mutable |
38374 | 11 |
import scala.annotation.tailrec |
38239
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
wenzelm
parents:
36956
diff
changeset
|
12 |
|
89a4d1028fb3
parse_spans: somewhat faster low-level implementation;
wenzelm
parents:
36956
diff
changeset
|
13 |
|
75393 | 14 |
object Thy_Syntax { |
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44388
diff
changeset
|
15 |
/** perspective **/ |
44388 | 16 |
|
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
17 |
def command_perspective( |
75393 | 18 |
node: Document.Node, |
19 |
perspective: Text.Perspective, |
|
20 |
overlays: Document.Node.Overlays |
|
21 |
): (Command.Perspective, Command.Perspective) = { |
|
76893 | 22 |
if (perspective.is_empty && overlays.is_empty) { |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
23 |
(Command.Perspective.empty, Command.Perspective.empty) |
76893 | 24 |
} |
44388 | 25 |
else { |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
26 |
val has_overlay = overlays.commands |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
27 |
val visible = new mutable.ListBuffer[Command] |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
28 |
val visible_overlay = new mutable.ListBuffer[Command] |
75393 | 29 |
@tailrec def check_ranges( |
30 |
ranges: List[Text.Range], |
|
31 |
commands: LazyList[(Command, Text.Offset)] |
|
32 |
): Unit = { |
|
44388 | 33 |
(ranges, commands) match { |
34 |
case (range :: more_ranges, (command, offset) #:: more_commands) => |
|
35 |
val command_range = command.range + offset |
|
36 |
range compare command_range match { |
|
37 |
case 0 => |
|
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
38 |
visible += command |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
39 |
visible_overlay += command |
44388 | 40 |
check_ranges(ranges, more_commands) |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
41 |
case c => |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
42 |
if (has_overlay(command)) visible_overlay += command |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
43 |
|
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
44 |
if (c < 0) check_ranges(more_ranges, commands) |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
45 |
else check_ranges(ranges, more_commands) |
44388 | 46 |
} |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
47 |
|
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
48 |
case (Nil, (command, _) #:: more_commands) => |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
49 |
if (has_overlay(command)) visible_overlay += command |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
50 |
|
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
51 |
check_ranges(Nil, more_commands) |
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
52 |
|
44388 | 53 |
case _ => |
54 |
} |
|
55 |
} |
|
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
56 |
|
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
57 |
val commands = |
56373
0605d90be6fc
tuned signature -- more explicit iterator terminology;
wenzelm
parents:
56372
diff
changeset
|
58 |
(if (overlays.is_empty) node.command_iterator(perspective.range) |
73368 | 59 |
else node.command_iterator()).to(LazyList) |
56373
0605d90be6fc
tuned signature -- more explicit iterator terminology;
wenzelm
parents:
56372
diff
changeset
|
60 |
check_ranges(perspective.ranges, commands) |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
61 |
(Command.Perspective(visible.toList), Command.Perspective(visible_overlay.toList)) |
44388 | 62 |
} |
63 |
} |
|
64 |
||
65 |
||
66 |
||
59699 | 67 |
/** header edits: graph structure and outer syntax **/ |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
68 |
|
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
69 |
private def header_edits( |
82785 | 70 |
session_base: Sessions.Base, |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
71 |
previous: Document.Version, |
75393 | 72 |
edits: List[Document.Edit_Text] |
73 |
): (List[Document.Node.Name], Document.Nodes, List[Document.Edit_Command]) = { |
|
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
74 |
val syntax_changed0 = new mutable.ListBuffer[Document.Node.Name] |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
75 |
var nodes = previous.nodes |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
76 |
val doc_edits = new mutable.ListBuffer[Document.Edit_Command] |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
77 |
|
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
78 |
edits foreach { |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
79 |
case (name, Document.Node.Deps(header)) if !session_base.loaded_theory(name) => |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
80 |
val node = nodes(name) |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
81 |
val update_header = |
59319 | 82 |
node.header.errors.nonEmpty || header.errors.nonEmpty || node.header != header |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
83 |
if (update_header) { |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
84 |
val node1 = node.update_header(header) |
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70625
diff
changeset
|
85 |
if (node.header.imports != node1.header.imports || |
60197 | 86 |
node.header.keywords != node1.header.keywords || |
63579 | 87 |
node.header.abbrevs != node1.header.abbrevs || |
60197 | 88 |
node.header.errors != node1.header.errors) syntax_changed0 += name |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
89 |
nodes += (name -> node1) |
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
90 |
doc_edits += (name -> Document.Node.Deps(header)) |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
91 |
} |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
92 |
case _ => |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
93 |
} |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
94 |
|
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
95 |
val syntax_changed = nodes.descendants(syntax_changed0.toList) |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
96 |
|
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
97 |
for (name <- syntax_changed) { |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
98 |
val node = nodes(name) |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
99 |
val syntax = |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
100 |
if (node.is_empty) None |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
101 |
else { |
59086
94b2690ad494
node-specific keywords, with session base syntax as default;
wenzelm
parents:
59077
diff
changeset
|
102 |
val header = node.header |
66721
ae38b8c0fdd9
more accurate node_syntax: avoid overall_syntax for PIDE edits;
wenzelm
parents:
66720
diff
changeset
|
103 |
val imports_syntax = |
66772 | 104 |
if (header.imports.nonEmpty) { |
82785 | 105 |
Outer_Syntax.merge(header.imports.map(session_base.node_syntax(nodes, _))) |
66772 | 106 |
} |
82785 | 107 |
else session_base.overall_syntax |
66721
ae38b8c0fdd9
more accurate node_syntax: avoid overall_syntax for PIDE edits;
wenzelm
parents:
66720
diff
changeset
|
108 |
Some(imports_syntax + header) |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
109 |
} |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
110 |
nodes += (name -> node.update_syntax(syntax)) |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
111 |
} |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
112 |
|
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
113 |
(syntax_changed, nodes, doc_edits.toList) |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
114 |
} |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
115 |
|
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
116 |
|
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
117 |
|
38374 | 118 |
/** text edits **/ |
119 |
||
48755
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
120 |
/* edit individual command source */ |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
121 |
|
75393 | 122 |
@tailrec def edit_text( |
82791 | 123 |
text_edits: List[Text.Edit], |
75393 | 124 |
commands: Linear_Set[Command] |
125 |
): Linear_Set[Command] = { |
|
82791 | 126 |
text_edits match { |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
127 |
case e :: es => |
65074
df14a0e872e6
improved performance of remove, e.g. relevant for Theories_Dockable.purge;
wenzelm
parents:
64854
diff
changeset
|
128 |
def insert_text(cmd: Option[Command], text: String): Linear_Set[Command] = |
82791 | 129 |
if (text.isEmpty) commands else commands.insert_after(cmd, Command.unparsed(text)) |
65074
df14a0e872e6
improved performance of remove, e.g. relevant for Theories_Dockable.purge;
wenzelm
parents:
64854
diff
changeset
|
130 |
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52887
diff
changeset
|
131 |
Document.Node.Commands.starts(commands.iterator).find { |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
132 |
case (cmd, cmd_start) => |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
133 |
e.can_edit(cmd.source, cmd_start) || |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
134 |
e.is_insert && e.start == cmd_start + cmd.length |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
135 |
} match { |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
136 |
case Some((cmd, cmd_start)) if e.can_edit(cmd.source, cmd_start) => |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
137 |
val (rest, text) = e.edit(cmd.source, cmd_start) |
82791 | 138 |
edit_text(rest.toList ::: es, insert_text(Some(cmd), text) - cmd) |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
139 |
|
71601 | 140 |
case Some((cmd, _)) => |
65074
df14a0e872e6
improved performance of remove, e.g. relevant for Theories_Dockable.purge;
wenzelm
parents:
64854
diff
changeset
|
141 |
edit_text(es, insert_text(Some(cmd), e.text)) |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
142 |
|
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
143 |
case None => |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
71601
diff
changeset
|
144 |
require(e.is_insert && e.start == 0, "bad text edit") |
65074
df14a0e872e6
improved performance of remove, e.g. relevant for Theories_Dockable.purge;
wenzelm
parents:
64854
diff
changeset
|
145 |
edit_text(es, insert_text(None, e.text)) |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
146 |
} |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
147 |
case Nil => commands |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
148 |
} |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
149 |
} |
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
150 |
|
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
151 |
|
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
152 |
/* reload theory from session store */ |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
153 |
|
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
154 |
def reload_theory( |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
155 |
session: Session, |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
156 |
doc_blobs: Document.Blobs, |
82798 | 157 |
node_name: Document.Node.Name, |
158 |
node: Document.Node, |
|
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
159 |
): Document.Node = { |
82798 | 160 |
require(node_name.is_theory) |
161 |
val theory = node_name.theory |
|
162 |
||
163 |
Exn.capture(session.read_theory(theory)) match { |
|
82795
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
164 |
case Exn.Res(command) => |
82798 | 165 |
val thy_changed = |
166 |
if (node.source.isEmpty || node.source == command.source) Nil |
|
167 |
else List(node_name.node) |
|
82795
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
168 |
val blobs_changed = |
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
169 |
for { |
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
170 |
case Exn.Res(blob) <- command.blobs |
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
171 |
(digest, _) <- blob.content |
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
172 |
doc_blob <- doc_blobs.get(blob.name) |
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
173 |
if digest != doc_blob.bytes.sha1_digest |
82798 | 174 |
} yield blob.name.node |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
175 |
|
82798 | 176 |
val changed = thy_changed ::: blobs_changed |
82795
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
177 |
val command1 = |
82798 | 178 |
if (changed.isEmpty) command |
179 |
else { |
|
180 |
val node_range = Text.Range(0, Symbol.length(node.source)) |
|
181 |
val msg = |
|
182 |
XML.Elem(Markup.Bad(Document_ID.make()), |
|
183 |
XML.string("Changed sources for loaded theory " + quote(theory) + |
|
184 |
":\n" + cat_lines(changed.map(a => " " + quote(a))))) |
|
185 |
Command.unparsed(node.source, theory = true, id = command.id, node_name = node_name, |
|
186 |
blobs_info = command.blobs_info, |
|
187 |
markups = Command.Markups.empty.add(Text.Info(node_range, msg))) |
|
188 |
} |
|
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
189 |
|
82798 | 190 |
node.update_commands(Linear_Set(command1)) |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
191 |
|
82795
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
192 |
case Exn.Exn(exn) => |
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
193 |
session.system_output(Output.error_message_text(Exn.print(exn))) |
82798 | 194 |
node |
82795
0bc9dbc61f7f
more robust: avoid crash on session database errors;
wenzelm
parents:
82793
diff
changeset
|
195 |
} |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
196 |
} |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
197 |
|
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
198 |
|
48755
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
199 |
/* reparse range of command spans */ |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
200 |
|
48748
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
wenzelm
parents:
48747
diff
changeset
|
201 |
@tailrec private def chop_common( |
75393 | 202 |
cmds: List[Command], |
203 |
blobs_spans: List[(Command.Blobs_Info, Command_Span.Span)] |
|
204 |
) : (List[Command], List[(Command.Blobs_Info, Command_Span.Span)]) = { |
|
55779 | 205 |
(cmds, blobs_spans) match { |
59803
88a89f01fc27
proper comparison of blobs_info (amending illtyped equality from 86a76300137e) -- avoid redundant update of unchanged commands;
wenzelm
parents:
59705
diff
changeset
|
206 |
case (cmd :: cmds, (blobs_info, span) :: rest) |
88a89f01fc27
proper comparison of blobs_info (amending illtyped equality from 86a76300137e) -- avoid redundant update of unchanged commands;
wenzelm
parents:
59705
diff
changeset
|
207 |
if cmd.blobs_info == blobs_info && cmd.span == span => chop_common(cmds, rest) |
55779 | 208 |
case _ => (cmds, blobs_spans) |
48748
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
wenzelm
parents:
48747
diff
changeset
|
209 |
} |
55779 | 210 |
} |
48748
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
wenzelm
parents:
48747
diff
changeset
|
211 |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
212 |
private def reparse_spans( |
56208 | 213 |
resources: Resources, |
63584
68751fe1c036
tuned signature -- prover-independence is presently theoretical;
wenzelm
parents:
63579
diff
changeset
|
214 |
syntax: Outer_Syntax, |
76904
e27d097d7d15
tuned signature: avoid confusion with Document.Node.Blob and Command.Blob;
wenzelm
parents:
76903
diff
changeset
|
215 |
get_blob: Document.Node.Name => Option[Document.Blobs.Item], |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
216 |
can_import: Document.Node.Name => Boolean, |
59699 | 217 |
node_name: Document.Node.Name, |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
218 |
commands: Linear_Set[Command], |
82792 | 219 |
first: Command, |
220 |
last: Command |
|
75393 | 221 |
): Linear_Set[Command] = { |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
222 |
require(!resources.session_base.loaded_theory(node_name)) |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
223 |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
224 |
val cmds0 = commands.iterator(first, last).toList |
55779 | 225 |
val blobs_spans0 = |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
226 |
syntax.parse_spans(cmds0.iterator.map(_.source).mkString).map(span => |
59705 | 227 |
(Command.blobs_info(resources, syntax, get_blob, can_import, node_name, span), span)) |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
228 |
|
55779 | 229 |
val (cmds1, blobs_spans1) = chop_common(cmds0, blobs_spans0) |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
230 |
|
55779 | 231 |
val (rev_cmds2, rev_blobs_spans2) = chop_common(cmds1.reverse, blobs_spans1.reverse) |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
232 |
val cmds2 = rev_cmds2.reverse |
55779 | 233 |
val blobs_spans2 = rev_blobs_spans2.reverse |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
234 |
|
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
235 |
cmds2 match { |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
236 |
case Nil => |
55779 | 237 |
assert(blobs_spans2.isEmpty) |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
238 |
commands |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
239 |
case cmd :: _ => |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
240 |
val hook = commands.prev(cmd) |
54462 | 241 |
val inserted = |
59684 | 242 |
blobs_spans2.map({ case (blobs, span) => |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
243 |
Command(Document_ID.make(), node_name, blobs, span) }) |
73359 | 244 |
cmds2.foldLeft(commands)(_ - _).append_after(hook, inserted) |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
245 |
} |
48748
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
wenzelm
parents:
48747
diff
changeset
|
246 |
} |
89b4e7d83d6f
refined recover_spans: take visible range into account, reparse and trim results -- to improve editing experience wrt. unbalanced quotations etc.;
wenzelm
parents:
48747
diff
changeset
|
247 |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
248 |
|
48755
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
249 |
/* main */ |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
250 |
|
75393 | 251 |
def diff_commands( |
252 |
old_cmds: Linear_Set[Command], |
|
253 |
new_cmds: Linear_Set[Command] |
|
254 |
) : List[Command.Edit] = { |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
255 |
val removed = old_cmds.iterator.filter(!new_cmds.contains(_)).toList |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
256 |
val inserted = new_cmds.iterator.filter(!old_cmds.contains(_)).toList |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
257 |
|
63866 | 258 |
removed.map(cmd => (old_cmds.prev(cmd), None)) reverse_::: |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
259 |
inserted.map(cmd => (new_cmds.prev(cmd), Some(cmd))) |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
260 |
} |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
261 |
|
54513 | 262 |
private def text_edit( |
56208 | 263 |
resources: Resources, |
63584
68751fe1c036
tuned signature -- prover-independence is presently theoretical;
wenzelm
parents:
63579
diff
changeset
|
264 |
syntax: Outer_Syntax, |
76904
e27d097d7d15
tuned signature: avoid confusion with Document.Node.Blob and Command.Blob;
wenzelm
parents:
76903
diff
changeset
|
265 |
get_blob: Document.Node.Name => Option[Document.Blobs.Item], |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
266 |
can_import: Document.Node.Name => Boolean, |
54513 | 267 |
reparse_limit: Int, |
76893 | 268 |
node: Document.Node, |
269 |
edit: Document.Edit_Text |
|
75393 | 270 |
): Document.Node = { |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
271 |
val session_base = resources.session_base |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
272 |
|
59704 | 273 |
/* recover command spans after edits */ |
274 |
// FIXME somewhat slow |
|
275 |
def recover_spans( |
|
276 |
name: Document.Node.Name, |
|
277 |
perspective: Command.Perspective, |
|
75393 | 278 |
commands: Linear_Set[Command] |
279 |
): Linear_Set[Command] = { |
|
59704 | 280 |
val is_visible = perspective.commands.toSet |
281 |
||
282 |
def next_invisible(cmds: Linear_Set[Command], from: Command): Command = |
|
283 |
cmds.iterator(from).dropWhile(cmd => !cmd.is_proper || is_visible(cmd)) |
|
284 |
.find(_.is_proper) getOrElse cmds.last |
|
285 |
||
286 |
@tailrec def recover(cmds: Linear_Set[Command]): Linear_Set[Command] = |
|
287 |
cmds.find(_.is_unparsed) match { |
|
288 |
case Some(first_unparsed) => |
|
289 |
val first = next_invisible(cmds.reverse, first_unparsed) |
|
290 |
val last = next_invisible(cmds, first_unparsed) |
|
291 |
recover( |
|
59705 | 292 |
reparse_spans(resources, syntax, get_blob, can_import, name, cmds, first, last)) |
59704 | 293 |
case None => cmds |
294 |
} |
|
295 |
recover(commands) |
|
296 |
} |
|
297 |
||
48755
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
298 |
edit match { |
76903 | 299 |
case (_, Document.Node.Blob(blob)) => Document.Node.init_blob(blob) |
54562
301a721af68b
clarified node edits sent to prover -- Clear/Blob only required for text edits within editor;
wenzelm
parents:
54524
diff
changeset
|
300 |
|
48755
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
301 |
case (name, Document.Node.Edits(text_edits)) => |
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56316
diff
changeset
|
302 |
if (name.is_theory) { |
82791 | 303 |
val commands1 = edit_text(text_edits, node.commands) |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
304 |
val commands2 = |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
305 |
if (session_base.loaded_theory(name)) commands1 |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
306 |
else recover_spans(name, node.perspective.visible, commands1) |
55435
662e0fd39823
maintain blob edits within history, which is important for Snapshot.convert/revert;
wenzelm
parents:
55431
diff
changeset
|
307 |
node.update_commands(commands2) |
662e0fd39823
maintain blob edits within history, which is important for Snapshot.convert/revert;
wenzelm
parents:
55431
diff
changeset
|
308 |
} |
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56316
diff
changeset
|
309 |
else 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:
48754
diff
changeset
|
310 |
|
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
311 |
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:
48754
diff
changeset
|
312 |
|
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
313 |
case (name, Document.Node.Perspective(_, _, _)) if session_base.loaded_theory(name) => node |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
314 |
|
52849 | 315 |
case (name, Document.Node.Perspective(required, text_perspective, overlays)) => |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
316 |
val (visible, visible_overlay) = command_perspective(node, text_perspective, overlays) |
76702 | 317 |
val perspective: Document.Node.Perspective_Command.T = |
52861
e93d73b51fd0
commands with overlay remain visible, to avoid loosing printed output;
wenzelm
parents:
52849
diff
changeset
|
318 |
Document.Node.Perspective(required, visible_overlay, overlays) |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
319 |
if (node.same_perspective(text_perspective, perspective)) node |
59703 | 320 |
else { |
321 |
/* consolidate unfinished spans */ |
|
322 |
val is_visible = visible.commands.toSet |
|
323 |
val commands = node.commands |
|
324 |
val commands1 = |
|
325 |
if (is_visible.isEmpty) commands |
|
326 |
else { |
|
327 |
commands.find(_.is_unfinished) match { |
|
328 |
case Some(first_unfinished) => |
|
329 |
commands.reverse.find(is_visible) match { |
|
330 |
case Some(last_visible) => |
|
331 |
val it = commands.iterator(last_visible) |
|
332 |
var last = last_visible |
|
333 |
var i = 0 |
|
334 |
while (i < reparse_limit && it.hasNext) { |
|
73344 | 335 |
last = it.next() |
59703 | 336 |
i += last.length |
337 |
} |
|
59705 | 338 |
reparse_spans(resources, syntax, get_blob, can_import, |
339 |
name, commands, first_unfinished, last) |
|
59703 | 340 |
case None => commands |
341 |
} |
|
342 |
case None => commands |
|
343 |
} |
|
344 |
} |
|
345 |
node.update_perspective(text_perspective, perspective).update_commands(commands1) |
|
346 |
} |
|
48755
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
347 |
} |
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
348 |
} |
393a37003851
apply all text edits to each node, before determining the resulting doc_edits -- allow several iterations to consolidate spans etc.;
wenzelm
parents:
48754
diff
changeset
|
349 |
|
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
350 |
def parse_change( |
82786 | 351 |
session: Session, |
75393 | 352 |
previous: Document.Version, |
353 |
doc_blobs: Document.Blobs, |
|
354 |
edits: List[Document.Edit_Text], |
|
355 |
consolidate: List[Document.Node.Name] |
|
356 |
): Session.Change = { |
|
82786 | 357 |
val resources = session.resources |
82785 | 358 |
val session_base = resources.session_base |
82789 | 359 |
val reparse_limit = session.reparse_limit |
82785 | 360 |
|
361 |
val (syntax_changed, nodes0, doc_edits0) = header_edits(session_base, previous, edits) |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
362 |
|
76904
e27d097d7d15
tuned signature: avoid confusion with Document.Node.Blob and Command.Blob;
wenzelm
parents:
76903
diff
changeset
|
363 |
def get_blob(name: Document.Node.Name): Option[Document.Blobs.Item] = |
56336 | 364 |
doc_blobs.get(name) orElse previous.nodes(name).get_blob |
365 |
||
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
366 |
def can_import(name: Document.Node.Name): Boolean = |
82785 | 367 |
session_base.loaded_theory(name) || nodes0(name).has_header |
54518
81a9a54c57fc
always reparse nodes with thy_load commands, to update inlined files;
wenzelm
parents:
54517
diff
changeset
|
368 |
|
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
369 |
val (doc_edits, version) = |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
370 |
if (edits.isEmpty) (Nil, Document.Version.make(previous.nodes)) |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
371 |
else { |
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
372 |
val reparse = |
73359 | 373 |
nodes0.iterator.foldLeft(syntax_changed) { |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
374 |
case (reparse, (name, node)) => |
76893 | 375 |
if (node.load_commands_changed(doc_blobs) && !reparse.contains(name)) { |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
376 |
name :: reparse |
76893 | 377 |
} |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
378 |
else reparse |
73359 | 379 |
} |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
380 |
val reparse_set = reparse.toSet |
46946
acc8ebf980ca
more explicit header_edits before main text_edits;
wenzelm
parents:
46942
diff
changeset
|
381 |
|
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
382 |
var nodes = nodes0 |
82787 | 383 |
val doc_edits = mutable.ListBuffer.from(doc_edits0) |
54521
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
wenzelm
parents:
54519
diff
changeset
|
384 |
|
82788
5afb8d0d418e
eliminate odd workaround from Aug-2012 (see 393a37003851);
wenzelm
parents:
82787
diff
changeset
|
385 |
val node_edits = (edits ::: reparse.map((_, Document.Node.Edits(Nil)))).groupBy(_._1) |
38374 | 386 |
|
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
387 |
node_edits foreach { |
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
388 |
case (name, edits) => |
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
389 |
val node = nodes(name) |
82785 | 390 |
val syntax = session_base.node_syntax(nodes, name) |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
391 |
val commands = node.commands |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48748
diff
changeset
|
392 |
|
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
393 |
val node1 = |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
394 |
if (!session_base.loaded_theory(name) && reparse_set(name) && commands.nonEmpty) { |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
395 |
node.update_commands( |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
396 |
reparse_spans(resources, syntax, get_blob, can_import, name, |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
397 |
commands, commands.head, commands.last)) |
76893 | 398 |
} |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
399 |
else node |
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
400 |
val node2 = |
73359 | 401 |
edits.foldLeft(node1)( |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
402 |
text_edit(resources, syntax, get_blob, can_import, reparse_limit, _, _)) |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
403 |
val node3 = |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
404 |
if (session_base.loaded_theory(name)) { |
82798 | 405 |
reload_theory(session, doc_blobs, name, node2) |
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
406 |
} |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
407 |
else if (reparse_set(name)) { |
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59699
diff
changeset
|
408 |
text_edit(resources, syntax, get_blob, can_import, reparse_limit, |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
409 |
node2, (name, node2.edit_perspective)) |
76893 | 410 |
} |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
411 |
else node2 |
54521
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
wenzelm
parents:
54519
diff
changeset
|
412 |
|
76893 | 413 |
if (!node.same_perspective(node3.text_perspective, node3.perspective)) { |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
414 |
doc_edits += (name -> node3.perspective) |
76893 | 415 |
} |
54521
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
wenzelm
parents:
54519
diff
changeset
|
416 |
|
82793
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
417 |
if (!session_base.loaded_theory(name)) { |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
418 |
doc_edits += (name -> Document.Node.Edits(diff_commands(commands, node3.commands))) |
fe8598c92be7
basic support to reload theory markup from session store;
wenzelm
parents:
82792
diff
changeset
|
419 |
} |
59372
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
420 |
|
503739360344
proper update of perspective after implicit edit due to reparse (e.g. ~~/src/HOL/Nat.thy);
wenzelm
parents:
59319
diff
changeset
|
421 |
nodes += (name -> node3) |
56316
b1cf8ddc2e04
propagate deps_changed, to resolve missing files without requiring jEdit events (e.g. buffer load/save);
wenzelm
parents:
56315
diff
changeset
|
422 |
} |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
57906
diff
changeset
|
423 |
(doc_edits.toList.filterNot(_._2.is_void), Document.Version.make(nodes)) |
54513 | 424 |
} |
425 |
||
68336
09ac56914b29
Document.update includes node consolidation / presentation as regular print operation: avoid user operations on protocol thread;
wenzelm
parents:
66772
diff
changeset
|
426 |
Session.Change( |
70796
2739631ac368
discontinued pointless dump_checkpoint and share_common_data -- superseded by base logic image in Isabelle/MMT;
wenzelm
parents:
70638
diff
changeset
|
427 |
previous, syntax_changed, syntax_changed.nonEmpty, doc_edits, consolidate, version) |
38374 | 428 |
} |
34268 | 429 |
} |