author | wenzelm |
Fri, 03 Jul 2020 17:00:41 +0200 | |
changeset 71993 | 088e3aa85250 |
parent 71680 | e20e117c3735 |
child 76804 | 3e8340fcaa16 |
permissions | -rw-r--r-- |
28405 | 1 |
(* Title: Pure/context_position.ML |
2 |
Author: Makarius |
|
3 |
||
28409 | 4 |
Context position visibility flag. |
28405 | 5 |
*) |
6 |
||
7 |
signature CONTEXT_POSITION = |
|
8 |
sig |
|
55672
5e25cc741ab9
support for completion within the formal context;
wenzelm
parents:
52700
diff
changeset
|
9 |
val is_visible_generic: Context.generic -> bool |
28405 | 10 |
val is_visible: Proof.context -> bool |
52700 | 11 |
val is_visible_global: theory -> bool |
60858 | 12 |
val set_visible_generic: bool -> Context.generic -> Context.generic |
28405 | 13 |
val set_visible: bool -> Proof.context -> Proof.context |
52700 | 14 |
val set_visible_global: bool -> theory -> theory |
57858
39d9c7f175e0
refined context visibility again (amending f5f9fad3321c, 8e3e004f1c31): avoid spurious warning due to global config options;
wenzelm
parents:
56333
diff
changeset
|
15 |
val is_really_visible: Proof.context -> bool |
39d9c7f175e0
refined context visibility again (amending f5f9fad3321c, 8e3e004f1c31): avoid spurious warning due to global config options;
wenzelm
parents:
56333
diff
changeset
|
16 |
val not_really: Proof.context -> Proof.context |
63030
4e7eff53bee7
avoid massive multiplication of reports due to interpretation;
wenzelm
parents:
60858
diff
changeset
|
17 |
val restore_visible_generic: Context.generic -> Context.generic -> Context.generic |
28405 | 18 |
val restore_visible: Proof.context -> Proof.context -> Proof.context |
52700 | 19 |
val restore_visible_global: theory -> theory -> theory |
71675 | 20 |
val pide_reports: unit -> bool |
21 |
val reports_enabled_generic: Context.generic -> bool |
|
22 |
val reports_enabled: Proof.context -> bool |
|
23 |
val reports_enabled_global: theory -> bool |
|
55923 | 24 |
val is_reported_generic: Context.generic -> Position.T -> bool |
25 |
val is_reported: Proof.context -> Position.T -> bool |
|
71674 | 26 |
val is_reported_global: theory -> Position.T -> bool |
47005
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
wenzelm
parents:
46874
diff
changeset
|
27 |
val report_generic: Context.generic -> Position.T -> Markup.T -> unit |
39507
839873937ddd
tuned signature of (Context_)Position.report variants;
wenzelm
parents:
39440
diff
changeset
|
28 |
val reported_text: Proof.context -> Position.T -> Markup.T -> string -> string |
839873937ddd
tuned signature of (Context_)Position.report variants;
wenzelm
parents:
39440
diff
changeset
|
29 |
val report_text: Proof.context -> Position.T -> Markup.T -> string -> unit |
839873937ddd
tuned signature of (Context_)Position.report variants;
wenzelm
parents:
39440
diff
changeset
|
30 |
val report: Proof.context -> Position.T -> Markup.T -> unit |
48767 | 31 |
val reports_text: Proof.context -> Position.report_text list -> unit |
71674 | 32 |
val reports_generic: Context.generic -> Position.report list -> unit |
44736 | 33 |
val reports: Proof.context -> Position.report list -> unit |
71674 | 34 |
val reports_global: theory -> Position.report list -> unit |
28405 | 35 |
end; |
36 |
||
33383 | 37 |
structure Context_Position: CONTEXT_POSITION = |
28405 | 38 |
struct |
39 |
||
71674 | 40 |
(* visible context *) |
41 |
||
71680 | 42 |
val really = Config.declare_bool ("really", Position.none) (K true); |
43 |
val visible = Config.declare_bool ("visible", Position.none) (K true); |
|
47813 | 44 |
|
71680 | 45 |
val is_visible_generic = Config.apply_generic visible; |
46 |
val is_visible = Config.apply visible; |
|
47 |
val is_visible_global = Config.apply_global visible; |
|
48 |
||
49 |
val set_visible_generic = Config.put_generic visible; |
|
50 |
val set_visible = Config.put visible; |
|
51 |
val set_visible_global = Config.put_global visible; |
|
28405 | 52 |
|
71680 | 53 |
val is_really = Config.apply really; |
57858
39d9c7f175e0
refined context visibility again (amending f5f9fad3321c, 8e3e004f1c31): avoid spurious warning due to global config options;
wenzelm
parents:
56333
diff
changeset
|
54 |
fun is_really_visible ctxt = is_really ctxt andalso is_visible ctxt; |
71680 | 55 |
val not_really = Config.put really false; |
57858
39d9c7f175e0
refined context visibility again (amending f5f9fad3321c, 8e3e004f1c31): avoid spurious warning due to global config options;
wenzelm
parents:
56333
diff
changeset
|
56 |
|
71680 | 57 |
fun restore_visible_generic context = |
58 |
Config.restore_generic really context #> |
|
59 |
Config.restore_generic visible context; |
|
60 |
||
61 |
val restore_visible = Context.proof_map o restore_visible_generic o Context.Proof; |
|
62 |
val restore_visible_global = Context.theory_map o restore_visible_generic o Context.Theory; |
|
38831
4933a3dfd745
more careful treatment of context visibility flag wrt. spurious warnings;
wenzelm
parents:
38481
diff
changeset
|
63 |
|
71674 | 64 |
|
65 |
(* PIDE reports *) |
|
66 |
||
71675 | 67 |
fun pide_reports () = Options.default_bool "pide_reports"; |
68 |
||
69 |
fun reports_enabled_generic context = pide_reports () andalso is_visible_generic context; |
|
70 |
val reports_enabled = reports_enabled_generic o Context.Proof; |
|
71 |
val reports_enabled_global = reports_enabled_generic o Context.Theory; |
|
72 |
||
73 |
fun is_reported_generic context pos = |
|
74 |
reports_enabled_generic context andalso Position.is_reported pos; |
|
71674 | 75 |
|
76 |
val is_reported = is_reported_generic o Context.Proof; |
|
77 |
val is_reported_global = is_reported_generic o Context.Theory; |
|
55923 | 78 |
|
47005
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
wenzelm
parents:
46874
diff
changeset
|
79 |
fun report_generic context pos markup = |
55923 | 80 |
if is_reported_generic context pos then |
56333
38f1422ef473
support bulk messages consisting of small string segments, which are more healthy to the Poly/ML RTS and might prevent spurious GC crashes such as MTGCProcessMarkPointers::ScanAddressesInObject;
wenzelm
parents:
56294
diff
changeset
|
81 |
Output.report [Position.reported_text pos markup ""] |
47005
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
wenzelm
parents:
46874
diff
changeset
|
82 |
else (); |
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
wenzelm
parents:
46874
diff
changeset
|
83 |
|
39507
839873937ddd
tuned signature of (Context_)Position.report variants;
wenzelm
parents:
39440
diff
changeset
|
84 |
fun reported_text ctxt pos markup txt = |
55923 | 85 |
if is_reported ctxt pos then Position.reported_text pos markup txt else ""; |
38481
81ec258c4cd3
Output_Position.report_text -- markup with potential "arguments";
wenzelm
parents:
38237
diff
changeset
|
86 |
|
56333
38f1422ef473
support bulk messages consisting of small string segments, which are more healthy to the Poly/ML RTS and might prevent spurious GC crashes such as MTGCProcessMarkPointers::ScanAddressesInObject;
wenzelm
parents:
56294
diff
changeset
|
87 |
fun report_text ctxt pos markup txt = Output.report [reported_text ctxt pos markup txt]; |
39507
839873937ddd
tuned signature of (Context_)Position.report variants;
wenzelm
parents:
39440
diff
changeset
|
88 |
fun report ctxt pos markup = report_text ctxt pos markup ""; |
28405 | 89 |
|
71675 | 90 |
fun reports_text ctxt reps = |
91 |
if reports_enabled ctxt then Position.reports_text reps else (); |
|
92 |
||
93 |
fun reports_generic context reps = |
|
94 |
if reports_enabled_generic context then Position.reports reps else (); |
|
71674 | 95 |
|
96 |
val reports = reports_generic o Context.Proof; |
|
97 |
val reports_global = reports_generic o Context.Theory; |
|
44736 | 98 |
|
28405 | 99 |
end; |