author | wenzelm |
Tue, 08 Apr 2014 12:31:17 +0200 | |
changeset 56463 | 013dfac0811a |
parent 56462 | b64b0cb845fe |
child 56468 | 30128d1acfbc |
permissions | -rw-r--r-- |
36676 | 1 |
/* Title: Pure/PIDE/command.scala |
2 |
Author: Fabian Immler, TU Munich |
|
3 |
Author: Makarius |
|
4 |
||
52536 | 5 |
Prover commands with accumulated results from execution. |
36676 | 6 |
*/ |
34407 | 7 |
|
34871
e596a0b71f3c
incorporate "proofdocument" part into main Isabelle/Pure.jar -- except for html_panel.scala, which depends on external library (Lobo/Cobra browser);
wenzelm
parents:
34865
diff
changeset
|
8 |
package isabelle |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
|
34451 | 10 |
|
45644 | 11 |
import scala.collection.mutable |
38872 | 12 |
import scala.collection.immutable.SortedMap |
13 |
||
14 |
||
34637 | 15 |
object Command |
16 |
{ |
|
52849 | 17 |
type Edit = (Option[Command], Option[Command]) |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
18 |
type Blob = Exn.Result[(Document.Node.Name, Option[(SHA1.Digest, Chunk.File)])] |
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
19 |
|
52849 | 20 |
|
21 |
||
38361 | 22 |
/** accumulated results from prover **/ |
23 |
||
50507 | 24 |
/* results */ |
25 |
||
26 |
object Results |
|
27 |
{ |
|
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
51494
diff
changeset
|
28 |
type Entry = (Long, XML.Tree) |
50507 | 29 |
val empty = new Results(SortedMap.empty) |
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
30 |
def make(es: List[Results.Entry]): Results = (empty /: es)(_ + _) |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
31 |
def merge(rs: List[Results]): Results = (empty /: rs)(_ ++ _) |
50507 | 32 |
} |
33 |
||
51494 | 34 |
final class Results private(private val rep: SortedMap[Long, XML.Tree]) |
50507 | 35 |
{ |
36 |
def defined(serial: Long): Boolean = rep.isDefinedAt(serial) |
|
37 |
def get(serial: Long): Option[XML.Tree] = rep.get(serial) |
|
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
38 |
def iterator: Iterator[Results.Entry] = rep.iterator |
50508
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
39 |
|
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
51494
diff
changeset
|
40 |
def + (entry: Results.Entry): Results = |
50508
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
41 |
if (defined(entry._1)) this |
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
42 |
else new Results(rep + entry) |
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
43 |
|
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
44 |
def ++ (other: Results): Results = |
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
45 |
if (this eq other) this |
5b7150395568
tuned implementation according to Library.insert/merge in ML;
wenzelm
parents:
50507
diff
changeset
|
46 |
else if (rep.isEmpty) other |
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
47 |
else (this /: other.iterator)(_ + _) |
50540 | 48 |
|
51494 | 49 |
override def hashCode: Int = rep.hashCode |
50 |
override def equals(that: Any): Boolean = |
|
51 |
that match { |
|
52 |
case other: Results => rep == other.rep |
|
53 |
case _ => false |
|
54 |
} |
|
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
55 |
override def toString: String = iterator.mkString("Results(", ", ", ")") |
50507 | 56 |
} |
57 |
||
58 |
||
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
59 |
/* source chunks */ |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
60 |
|
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
61 |
abstract class Chunk |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
62 |
{ |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
63 |
def name: Chunk.Name |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
64 |
def range: Text.Range |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
65 |
def symbol_index: Symbol.Index |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
66 |
|
56463 | 67 |
private lazy val hash: Int = (name, range, symbol_index).hashCode |
68 |
override def hashCode: Int = hash |
|
69 |
override def equals(that: Any): Boolean = |
|
70 |
that match { |
|
71 |
case other: Chunk => |
|
72 |
hash == other.hash && |
|
73 |
name == other.name && |
|
74 |
range == other.range && |
|
75 |
symbol_index == other.symbol_index |
|
76 |
case _ => false |
|
77 |
} |
|
78 |
override def toString: String = "Command.Chunk(" + name + ")" |
|
79 |
||
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
80 |
def decode(symbol_offset: Symbol.Offset): Text.Offset = symbol_index.decode(symbol_offset) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
81 |
def decode(symbol_range: Symbol.Range): Text.Range = symbol_index.decode(symbol_range) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
82 |
def incorporate(symbol_range: Symbol.Range): Option[Text.Range] = |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
83 |
{ |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
84 |
def in(r: Symbol.Range): Option[Text.Range] = |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
85 |
range.try_restrict(decode(r)) match { |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
86 |
case Some(r1) if !r1.is_singularity => Some(r1) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
87 |
case _ => None |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
88 |
} |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
89 |
in(symbol_range) orElse in(symbol_range - 1) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
90 |
} |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
91 |
} |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
92 |
|
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
93 |
object Chunk |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
94 |
{ |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
95 |
sealed abstract class Name |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
96 |
case object Self extends Name |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
97 |
case class File_Name(file_name: String) extends Name |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
98 |
|
56463 | 99 |
class File(file_name: String, text: CharSequence) extends Chunk |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
100 |
{ |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
101 |
val name = Chunk.File_Name(file_name) |
56463 | 102 |
val range = Text.Range(0, text.length) |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
103 |
val symbol_index = Symbol.Index(text) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
104 |
} |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
105 |
} |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
106 |
|
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
107 |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
108 |
/* markup */ |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
109 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
110 |
object Markup_Index |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
111 |
{ |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
112 |
val markup: Markup_Index = Markup_Index(false, Chunk.Self) |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
113 |
} |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
114 |
|
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
115 |
sealed case class Markup_Index(status: Boolean, chunk_name: Chunk.Name) |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
116 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
117 |
object Markups |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
118 |
{ |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
119 |
val empty: Markups = new Markups(Map.empty) |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
120 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
121 |
def init(markup: Markup_Tree): Markups = |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
122 |
new Markups(Map(Markup_Index.markup -> markup)) |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
123 |
} |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
124 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
125 |
final class Markups private(private val rep: Map[Markup_Index, Markup_Tree]) |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
126 |
{ |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
127 |
def apply(index: Markup_Index): Markup_Tree = |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
128 |
rep.getOrElse(index, Markup_Tree.empty) |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
129 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
130 |
def add(index: Markup_Index, markup: Text.Markup): Markups = |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
131 |
new Markups(rep + (index -> (this(index) + markup))) |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
132 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
133 |
override def hashCode: Int = rep.hashCode |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
134 |
override def equals(that: Any): Boolean = |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
135 |
that match { |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
136 |
case other: Markups => rep == other.rep |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
137 |
case _ => false |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
138 |
} |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
139 |
override def toString: String = rep.iterator.mkString("Markups(", ", ", ")") |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
140 |
} |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
141 |
|
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
142 |
|
50507 | 143 |
/* state */ |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
144 |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
145 |
object State |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
146 |
{ |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
147 |
def merge_results(states: List[State]): Command.Results = |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
148 |
Results.merge(states.map(_.results)) |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
149 |
|
56301
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56299
diff
changeset
|
150 |
def merge_markup(states: List[State], index: Markup_Index, |
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56299
diff
changeset
|
151 |
range: Text.Range, elements: Document.Elements): Markup_Tree = |
1da7b4c33db9
more frugal merge of markup trees: filter wrt. subsequent query;
wenzelm
parents:
56299
diff
changeset
|
152 |
Markup_Tree.merge(states.map(_.markup(index)), range, elements) |
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
153 |
} |
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56295
diff
changeset
|
154 |
|
43714 | 155 |
sealed case class State( |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
156 |
command: Command, |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
157 |
status: List[Markup] = Nil, |
50507 | 158 |
results: Results = Results.empty, |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
159 |
markups: Markups = Markups.empty) |
38361 | 160 |
{ |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
161 |
lazy val protocol_status: Protocol.Status = |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
162 |
{ |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
163 |
val warnings = |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
164 |
if (results.iterator.exists(p => Protocol.is_warning(p._2))) |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
165 |
List(Markup(Markup.WARNING, Nil)) |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
166 |
else Nil |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
167 |
val errors = |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
168 |
if (results.iterator.exists(p => Protocol.is_error(p._2))) |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
169 |
List(Markup(Markup.ERROR, Nil)) |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
170 |
else Nil |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
171 |
Protocol.Status.make((warnings ::: errors ::: status).iterator) |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
172 |
} |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
173 |
|
55650 | 174 |
def markup(index: Markup_Index): Markup_Tree = markups(index) |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
175 |
|
49614 | 176 |
|
51494 | 177 |
def eq_content(other: State): Boolean = |
178 |
command.source == other.command.source && |
|
179 |
status == other.status && |
|
180 |
results == other.results && |
|
55434 | 181 |
markups == other.markups |
38361 | 182 |
|
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
183 |
private def add_status(st: Markup): State = |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
184 |
copy(status = st :: status) |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
185 |
|
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
186 |
private def add_markup(status: Boolean, chunk_name: Command.Chunk.Name, m: Text.Markup): State = |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
187 |
{ |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
188 |
val markups1 = |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
189 |
if (status || Protocol.liberal_status_elements(m.info.name)) |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
190 |
markups.add(Markup_Index(true, chunk_name), m) |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
191 |
else markups |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
192 |
copy(markups = markups1.add(Markup_Index(false, chunk_name), m)) |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
193 |
} |
38361 | 194 |
|
56295
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
55884
diff
changeset
|
195 |
def + (valid_id: Document_ID.Generic => Boolean, message: XML.Elem): State = |
38361 | 196 |
message match { |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
197 |
case XML.Elem(Markup(Markup.STATUS, _), msgs) => |
38714 | 198 |
(this /: msgs)((state, msg) => |
199 |
msg match { |
|
46152
793cecd4ffc0
accumulate status as regular markup for command range;
wenzelm
parents:
45709
diff
changeset
|
200 |
case elem @ XML.Elem(markup, Nil) => |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
201 |
state. |
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
202 |
add_status(markup). |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
203 |
add_markup(true, Command.Chunk.Self, Text.Info(command.proper_range, elem)) |
52536 | 204 |
case _ => |
55618 | 205 |
System.err.println("Ignored status message: " + msg) |
52536 | 206 |
state |
38714 | 207 |
}) |
38581
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38579
diff
changeset
|
208 |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
209 |
case XML.Elem(Markup(Markup.REPORT, _), msgs) => |
38572
0fe2c01ef7da
Command.State: accumulate markup reports uniformly;
wenzelm
parents:
38564
diff
changeset
|
210 |
(this /: msgs)((state, msg) => |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
211 |
{ |
55618 | 212 |
def bad(): Unit = System.err.println("Ignored report message: " + msg) |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
213 |
|
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
214 |
msg match { |
55884
f2c0eaedd579
tuned signature -- emphasize symbol positions (prover) vs. decoded text offsets (editor);
wenzelm
parents:
55822
diff
changeset
|
215 |
case XML.Elem(Markup(name, |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
216 |
atts @ Position.Reported(id, chunk_name, symbol_range)), args) |
56295
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
55884
diff
changeset
|
217 |
if valid_id(id) => |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
218 |
command.chunks.get(chunk_name) match { |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
219 |
case Some(chunk) => |
55884
f2c0eaedd579
tuned signature -- emphasize symbol positions (prover) vs. decoded text offsets (editor);
wenzelm
parents:
55822
diff
changeset
|
220 |
chunk.incorporate(symbol_range) match { |
55548
a645277885cf
more uniform/robust restriction of reported positions, e.g. relevant for "bad" markup due to unclosed comment in ML file;
wenzelm
parents:
55434
diff
changeset
|
221 |
case Some(range) => |
55822
ccf2d784be97
incorporate chunk range that is 1 off end-of-input, for improved error positions (NB: command spans are tight, without trailing whitespace);
wenzelm
parents:
55785
diff
changeset
|
222 |
val props = Position.purge(atts) |
ccf2d784be97
incorporate chunk range that is 1 off end-of-input, for improved error positions (NB: command spans are tight, without trailing whitespace);
wenzelm
parents:
55785
diff
changeset
|
223 |
val info = Text.Info(range, XML.Elem(Markup(name, props), args)) |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
224 |
state.add_markup(false, chunk_name, info) |
55548
a645277885cf
more uniform/robust restriction of reported positions, e.g. relevant for "bad" markup due to unclosed comment in ML file;
wenzelm
parents:
55434
diff
changeset
|
225 |
case None => bad(); state |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
226 |
} |
55548
a645277885cf
more uniform/robust restriction of reported positions, e.g. relevant for "bad" markup due to unclosed comment in ML file;
wenzelm
parents:
55434
diff
changeset
|
227 |
case None => bad(); state |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
228 |
} |
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
229 |
|
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
230 |
case XML.Elem(Markup(name, atts), args) |
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
231 |
if !atts.exists({ case (a, _) => Markup.POSITION_PROPERTIES(a) }) => |
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
232 |
val range = command.proper_range |
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
233 |
val props = Position.purge(atts) |
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
234 |
val info: Text.Markup = Text.Info(range, XML.Elem(Markup(name, props), args)) |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
235 |
state.add_markup(false, Command.Chunk.Self, info) |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
236 |
|
55548
a645277885cf
more uniform/robust restriction of reported positions, e.g. relevant for "bad" markup due to unclosed comment in ML file;
wenzelm
parents:
55434
diff
changeset
|
237 |
case _ => /* FIXME bad(); */ state |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
238 |
} |
38361 | 239 |
}) |
52930
5fab62ae3532
retain original messages properties, e.g. for retrieval via Command.Results;
wenzelm
parents:
52849
diff
changeset
|
240 |
case XML.Elem(Markup(name, props), body) => |
5fab62ae3532
retain original messages properties, e.g. for retrieval via Command.Results;
wenzelm
parents:
52849
diff
changeset
|
241 |
props match { |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
242 |
case Markup.Serial(i) => |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
243 |
val message1 = XML.Elem(Markup(Markup.message(name), props), body) |
50163
c62ce309dc26
more abstract Sendback operations, with explicit id/exec_id properties;
wenzelm
parents:
50158
diff
changeset
|
244 |
val message2 = XML.Elem(Markup(name, props), body) |
c62ce309dc26
more abstract Sendback operations, with explicit id/exec_id properties;
wenzelm
parents:
50158
diff
changeset
|
245 |
|
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
246 |
var st = copy(results = results + (i -> message1)) |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
247 |
if (Protocol.is_inlined(message)) { |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
248 |
for { |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
249 |
(chunk_name, chunk) <- command.chunks |
56295
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
55884
diff
changeset
|
250 |
range <- Protocol.message_positions(valid_id, chunk, message) |
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
251 |
} st = st.add_markup(false, chunk_name, Text.Info(range, message2)) |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
252 |
} |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
253 |
st |
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
254 |
|
52536 | 255 |
case _ => |
55618 | 256 |
System.err.println("Ignored message without serial number: " + message) |
52536 | 257 |
this |
38872 | 258 |
} |
56295
a40e67ce4f84
clarified valid_id: always standardize towards static command.id;
wenzelm
parents:
55884
diff
changeset
|
259 |
} |
38361 | 260 |
} |
38367 | 261 |
|
262 |
||
55431
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
263 |
|
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
264 |
/** static content **/ |
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
265 |
|
45644 | 266 |
/* make commands */ |
267 |
||
54462 | 268 |
def name(span: List[Token]): String = |
269 |
span.find(_.is_command) match { case Some(tok) => tok.source case _ => "" } |
|
48745 | 270 |
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
271 |
private def source_span(span: List[Token]): (String, List[Token]) = |
45644 | 272 |
{ |
273 |
val source: String = |
|
48745 | 274 |
span match { |
45644 | 275 |
case List(tok) => tok.source |
48745 | 276 |
case _ => span.map(_.source).mkString |
45644 | 277 |
} |
278 |
||
48745 | 279 |
val span1 = new mutable.ListBuffer[Token] |
45644 | 280 |
var i = 0 |
48745 | 281 |
for (Token(kind, s) <- span) { |
45644 | 282 |
val n = s.length |
283 |
val s1 = source.substring(i, i + n) |
|
48745 | 284 |
span1 += Token(kind, s1) |
45644 | 285 |
i += n |
286 |
} |
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
287 |
(source, span1.toList) |
45644 | 288 |
} |
289 |
||
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
290 |
def apply( |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
291 |
id: Document_ID.Command, |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
292 |
node_name: Document.Node.Name, |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
293 |
blobs: List[Blob], |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
294 |
span: List[Token]): Command = |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
295 |
{ |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
296 |
val (source, span1) = source_span(span) |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
297 |
new Command(id, node_name, blobs, span1, source, Results.empty, Markup_Tree.empty) |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
298 |
} |
49414 | 299 |
|
55648
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
300 |
val empty: Command = Command(Document_ID.none, Document.Node.Name.empty, Nil, Nil) |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
301 |
|
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
302 |
def unparsed( |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
303 |
id: Document_ID.Command, |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
304 |
source: String, |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
305 |
results: Results, |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
306 |
markup: Markup_Tree): Command = |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
307 |
{ |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
308 |
val (source1, span) = source_span(List(Token(Token.Kind.UNPARSED, source))) |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
309 |
new Command(id, Document.Node.Name.empty, Nil, span, source1, results, markup) |
38f264741609
tuned signature -- avoid obscure default arguments;
wenzelm
parents:
55622
diff
changeset
|
310 |
} |
49414 | 311 |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
312 |
def unparsed(source: String): Command = |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
313 |
unparsed(Document_ID.none, source, Results.empty, Markup_Tree.empty) |
44384 | 314 |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
315 |
def rich_text(id: Document_ID.Command, results: Results, body: XML.Body): Command = |
49414 | 316 |
{ |
49466 | 317 |
val text = XML.content(body) |
318 |
val markup = Markup_Tree.from_XML(body) |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
319 |
unparsed(id, text, results, markup) |
49414 | 320 |
} |
49359
c1262d7389fb
refined output panel: more value-oriented approach to update and caret focus;
wenzelm
parents:
49037
diff
changeset
|
321 |
|
44384 | 322 |
|
323 |
/* perspective */ |
|
324 |
||
44474 | 325 |
object Perspective |
326 |
{ |
|
327 |
val empty: Perspective = Perspective(Nil) |
|
328 |
} |
|
44385
e7fdb008aa7d
propagate editor perspective through document model;
wenzelm
parents:
44384
diff
changeset
|
329 |
|
44474 | 330 |
sealed case class Perspective(commands: List[Command]) // visible commands in canonical order |
44385
e7fdb008aa7d
propagate editor perspective through document model;
wenzelm
parents:
44384
diff
changeset
|
331 |
{ |
44474 | 332 |
def same(that: Perspective): Boolean = |
333 |
{ |
|
334 |
val cmds1 = this.commands |
|
335 |
val cmds2 = that.commands |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48745
diff
changeset
|
336 |
require(!cmds1.exists(_.is_undefined)) |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48745
diff
changeset
|
337 |
require(!cmds2.exists(_.is_undefined)) |
44474 | 338 |
cmds1.length == cmds2.length && |
339 |
(cmds1.iterator zip cmds2.iterator).forall({ case (c1, c2) => c1.id == c2.id }) |
|
340 |
} |
|
44385
e7fdb008aa7d
propagate editor perspective through document model;
wenzelm
parents:
44384
diff
changeset
|
341 |
} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
342 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
343 |
|
38361 | 344 |
|
46712 | 345 |
final class Command private( |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
346 |
val id: Document_ID.Command, |
44615 | 347 |
val node_name: Document.Node.Name, |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
348 |
val blobs: List[Command.Blob], |
52535
b7badd371e4d
tuned signature -- eliminated pointless type synonym;
wenzelm
parents:
52531
diff
changeset
|
349 |
val span: List[Token], |
49414 | 350 |
val source: String, |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
351 |
val init_results: Command.Results, |
49414 | 352 |
val init_markup: Markup_Tree) |
34451 | 353 |
{ |
34859 | 354 |
/* classification */ |
34500
384427c750c8
state_results: separate buffer for messages from running command;
wenzelm
parents:
34497
diff
changeset
|
355 |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
356 |
def is_undefined: Boolean = id == Document_ID.none |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48745
diff
changeset
|
357 |
val is_unparsed: Boolean = span.exists(_.is_unparsed) |
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48745
diff
changeset
|
358 |
val is_unfinished: Boolean = span.exists(_.is_unfinished) |
44385
e7fdb008aa7d
propagate editor perspective through document model;
wenzelm
parents:
44384
diff
changeset
|
359 |
|
48599 | 360 |
val is_ignored: Boolean = !span.exists(_.is_proper) |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48745
diff
changeset
|
361 |
val is_malformed: Boolean = !is_ignored && (!span.head.is_command || span.exists(_.is_error)) |
47012
0e246130486b
clarified command span classification: strict Command.is_command, permissive Command.name;
wenzelm
parents:
46910
diff
changeset
|
362 |
def is_command: Boolean = !is_ignored && !is_malformed |
34859 | 363 |
|
54462 | 364 |
def name: String = Command.name(span) |
47012
0e246130486b
clarified command span classification: strict Command.is_command, permissive Command.name;
wenzelm
parents:
46910
diff
changeset
|
365 |
|
37129 | 366 |
override def toString = |
37373
25078ba44436
tuned Command.toString -- preserving uniqueness allows the Scala toplevel to print Linear_Set[Command] results without crashing;
wenzelm
parents:
37197
diff
changeset
|
367 |
id + "/" + (if (is_command) name else if (is_ignored) "IGNORED" else "MALFORMED") |
34495 | 368 |
|
34859 | 369 |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
370 |
/* blobs */ |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
371 |
|
55785 | 372 |
def blobs_changed(doc_blobs: Document.Blobs): Boolean = |
373 |
blobs.exists({ case Exn.Res((name, _)) => doc_blobs.changed(name) case _ => false }) |
|
374 |
||
54530
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54524
diff
changeset
|
375 |
def blobs_names: List[Document.Node.Name] = |
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54524
diff
changeset
|
376 |
for (Exn.Res((name, _)) <- blobs) yield name |
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54524
diff
changeset
|
377 |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
378 |
def blobs_digests: List[SHA1.Digest] = |
55431
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
379 |
for (Exn.Res((_, Some((digest, _)))) <- blobs) yield digest |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54517
diff
changeset
|
380 |
|
55432
9c53198dbb1c
maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents:
55431
diff
changeset
|
381 |
|
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
382 |
/* source chunks */ |
55431
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55430
diff
changeset
|
383 |
|
46813 | 384 |
def length: Int = source.length |
385 |
val range: Text.Range = Text.Range(0, length) |
|
386 |
||
387 |
val proper_range: Text.Range = |
|
51048
123be08eed88
clarified notion of Command.proper_range (according to Token.is_proper), especially relevant for Active.try_replace_command, to avoid loosing subsequent comments accidentally;
wenzelm
parents:
50540
diff
changeset
|
388 |
Text.Range(0, (length /: span.reverse.iterator.takeWhile(_.is_improper))(_ - _.source.length)) |
46813 | 389 |
|
38426 | 390 |
def source(range: Text.Range): String = source.substring(range.start, range.stop) |
38572
0fe2c01ef7da
Command.State: accumulate markup reports uniformly;
wenzelm
parents:
38564
diff
changeset
|
391 |
|
56462
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
392 |
val chunk: Command.Chunk = |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
393 |
new Command.Chunk { |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
394 |
def name: Command.Chunk.Name = Command.Chunk.Self |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
395 |
def range: Text.Range = Command.this.range |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
396 |
lazy val symbol_index = Symbol.Index(source) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
397 |
} |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
398 |
|
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
399 |
val chunks: Map[Command.Chunk.Name, Command.Chunk] = |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
400 |
((Command.Chunk.Self -> chunk) :: |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
401 |
(for (Exn.Res((name, Some((_, file)))) <- blobs) |
b64b0cb845fe
more explicit Command.Chunk types, less ooddities;
wenzelm
parents:
56395
diff
changeset
|
402 |
yield (Command.Chunk.File_Name(name.node) -> file))).toMap |
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
403 |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
404 |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
405 |
/* accumulated results */ |
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
406 |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
407 |
val init_state: Command.State = |
55649
1532ab0dc67b
more general / abstract Command.Markups, with separate index for status elements;
wenzelm
parents:
55648
diff
changeset
|
408 |
Command.State(this, results = init_results, markups = Command.Markups.init(init_markup)) |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52524
diff
changeset
|
409 |
|
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52524
diff
changeset
|
410 |
val empty_state: Command.State = Command.State(this) |
34676
9e725d34df7b
Command and Command_State handle results from prover as Accumulator
immler@in.tum.de
parents:
34675
diff
changeset
|
411 |
} |