equal
deleted
inserted
replaced
1 /* Title: Pure/General/completion.scala |
1 /* Title: Pure/General/completion.scala |
2 Author: Makarius |
2 Author: Makarius |
3 |
3 |
4 Semantic completion within the formal context (reported by prover). |
4 Semantic completion within the formal context (reported names). |
5 Syntactic completion of keywords and symbols, with abbreviations |
5 Syntactic completion of keywords and symbols, with abbreviations |
6 (based on language context). |
6 (based on language context). */ |
7 */ |
|
8 |
7 |
9 package isabelle |
8 package isabelle |
10 |
9 |
11 |
10 |
12 import scala.collection.immutable.SortedMap |
11 import scala.collection.immutable.SortedMap |
16 |
15 |
17 object Completion |
16 object Completion |
18 { |
17 { |
19 /** semantic completion **/ |
18 /** semantic completion **/ |
20 |
19 |
21 object Reported |
20 object Names |
22 { |
21 { |
23 object Elem |
22 object Info |
24 { |
23 { |
25 private def decode: XML.Decode.T[(String, List[String])] = |
24 def unapply(info: Text.Markup): Option[Names] = |
26 { |
25 info.info match { |
27 import XML.Decode._ |
26 case XML.Elem(Markup(Markup.COMPLETION, |
28 pair(string, list(string)) |
27 (Markup.TOTAL, Properties.Value.Int(total)) :: names), _) => |
29 } |
28 Some(Names(info.range, total, names.map(_._2))) |
30 |
|
31 def unapply(tree: XML.Tree): Option[Reported] = |
|
32 tree match { |
|
33 case XML.Elem(Markup(Markup.COMPLETION, _), body) => |
|
34 try { |
|
35 val (original, replacements) = decode(body) |
|
36 Some(Reported(original, replacements)) |
|
37 } |
|
38 catch { case _: XML.Error => None } |
|
39 case _ => None |
29 case _ => None |
40 } |
30 } |
41 } |
31 } |
42 } |
32 } |
43 |
33 |
44 sealed case class Reported(original: String, replacements: List[String]) |
34 sealed case class Names(range: Text.Range, total: Int, names: List[String]) |
45 |
35 |
46 |
36 |
47 |
37 |
48 /** syntactic completion **/ |
38 /** syntactic completion **/ |
49 |
39 |