# HG changeset patch # User wenzelm # Date 1521920730 -3600 # Node ID b45f0c0ea14f51ebcf3160b535164d844db24dd6 # Parent a3e5f08e6b589d93560646e6620a5002dfa59657 clarified theory node name; purge_theories: return purged, retained; tuned documentation; diff -r a3e5f08e6b58 -r b45f0c0ea14f src/Doc/System/Server.thy --- a/src/Doc/System/Server.thy Sat Mar 24 15:07:13 2018 +0100 +++ b/src/Doc/System/Server.thy Sat Mar 24 20:45:30 2018 +0100 @@ -509,6 +509,12 @@ connections and may be shared by different clients, as long as the internal session identifier is known. + \<^item> \<^bold>\type\ \node = {node_name: string, theory_name: string}\ represents the + internal node name of a theory. The \node_name\ is derived from the + canonical theory file-name (e.g.\ \<^verbatim>\"~~/src/HOL/ex/Seq.thy"\ after + normalization within the file-system). The \theory_name\ is the + session-qualified theory name (e.g.\ \<^verbatim>\HOL-ex.Seq\). + \<^item> \<^bold>\type\ \node_status = {ok: bool, total: int, unprocessed: int, running: int, warned: int, failed: int, finished: int, consolidated: bool}\ represents a formal theory node status of the PIDE document model. Fields @@ -888,15 +894,13 @@ \begin{tabular}{ll} \<^bold>\type\ \node_result =\ \\ - \quad\{node_name: string,\ \\ - \quad~~\theory: string,\ \\ - \quad~~\status: node_status,\ \\ + \quad\{status: node_status,\ \\ \quad~~\messages: [message]}\ \\[2ex] \<^bold>\type\ \use_theories_results =\ \\ \quad\{ok: bool,\ \\ \quad~~\errors: [message],\ \\ - \quad~~\nodes: [node_result]}\ \\[2ex] + \quad~~\nodes: [node \ node_result]}\ \\[2ex] \end{tabular} \<^medskip> @@ -928,9 +932,9 @@ \<^medskip> The \master_dir\ field specifies the master directory of imported theories: it acts like the ``current working directory'' for locating theory files. - This may be omitted if all entries of \theories\ use a session-qualified - theory name (e.g.\ \<^verbatim>\"HOL-Library.AList"\) or absolute path name (e.g.\ - \<^verbatim>\"~~/src/HOL/ex/Seq"\). + This may be omitted if all entries of \theories\ use an absolute path name + (e.g.\ \<^verbatim>\"~~/src/HOL/ex/Seq.thy"\) or session-qualified theory name (e.g.\ + \<^verbatim>\"HOL-ex/Seq"\). \<^medskip> The \pretty_margin\ field specifies the line width for pretty-printing. The @@ -961,10 +965,10 @@ The \nodes\ field provides detailed information about each imported theory node. The individual fields are as follows: - \<^item> \node_name\: the physical name for the theory node, based on its + \<^item> \node_name\: the canonical name for the theory node, based on its file-system location; - \<^item> \theory\: the logical theory name, e.g.\ \<^verbatim>\HOL-Library.AList\; + \<^item> \theory_name\: the logical theory name; \<^item> \status\: the overall node status, e.g.\ see the visualization in the \Theories\ panel of Isabelle/jEdit @{cite "isabelle-jedit"}; @@ -1040,8 +1044,9 @@ \node_name\. \<^medskip> - The \master_dir\ field specifies the master directory as in \<^verbatim>\use_theories\; - by passing its \nodes\ / \node_name\ results, the \master_dir\ is redundant. + The \master_dir\ field specifies the master directory as in \<^verbatim>\use_theories\. + It is redundant, when passing fully-qualified theory node names (e.g.\ + \node_name\ from \nodes\ in \use_theories_results\). \<^medskip> The \all\ field set to \<^verbatim>\true\ attempts to purge all presently loaded @@ -1052,8 +1057,11 @@ subsubsection \Results\ text \ - The \purged\ field reveals the \node_name\ of each theory that was actually - removed. + The \purged\ field gives the theory nodes that were actually removed. + + \<^medskip> + The \retained\ field gives the remaining theory nodes, i.e.\ the complement + of \purged\. \ end diff -r a3e5f08e6b58 -r b45f0c0ea14f src/Pure/PIDE/document.scala --- a/src/Pure/PIDE/document.scala Sat Mar 24 15:07:13 2018 +0100 +++ b/src/Pure/PIDE/document.scala Sat Mar 24 20:45:30 2018 +0100 @@ -130,6 +130,9 @@ def map(f: String => String): Name = copy(f(node), f(master_dir), theory) def map_theory(f: String => String): Name = copy(node, master_dir, f(theory)) + + def json: JSON.Object.T = + JSON.Object("node_name" -> node, "theory_name" -> theory) } sealed case class Entry(name: Node.Name, header: Node.Header) diff -r a3e5f08e6b58 -r b45f0c0ea14f src/Pure/Thy/thy_resources.scala --- a/src/Pure/Thy/thy_resources.scala Sat Mar 24 15:07:13 2018 +0100 +++ b/src/Pure/Thy/thy_resources.scala Sat Mar 24 20:45:30 2018 +0100 @@ -142,7 +142,7 @@ theories: List[String], qualifier: String = Sessions.DRAFT, master_dir: String = "", - all: Boolean = false): List[Document.Node.Name] = + all: Boolean = false): (List[Document.Node.Name], List[Document.Node.Name]) = resources.purge_theories(session, theories = theories, qualifier = qualifier, master_dir = master_dir, all = all) } @@ -294,7 +294,7 @@ theories: List[String], qualifier: String = Sessions.DRAFT, master_dir: String = "", - all: Boolean = false): List[Document.Node.Name] = + all: Boolean = false): (List[Document.Node.Name], List[Document.Node.Name]) = { val nodes = theories.map(import_name(qualifier, master_dir, _)) @@ -306,12 +306,14 @@ val purge = (if (all) all_nodes else nodes.filter(graph.defined(_))). filterNot(st.is_required(_)).toSet - val purged = all_nodes.filterNot(graph.all_preds(all_nodes.filterNot(purge)).toSet) + + val retain = graph.all_preds(all_nodes.filterNot(purge)).toSet + val (retained, purged) = all_nodes.partition(retain) val purge_edits = purged.flatMap(name => st.theories(name).purge_edits) session.update(Document.Blobs.empty, purge_edits) - (purged, st.remove_theories(purged)) + ((purged, retained), st.remove_theories(purged)) }) } } diff -r a3e5f08e6b58 -r b45f0c0ea14f src/Pure/Tools/server_commands.scala --- a/src/Pure/Tools/server_commands.scala Sat Mar 24 15:07:13 2018 +0100 +++ b/src/Pure/Tools/server_commands.scala Sat Mar 24 20:45:30 2018 +0100 @@ -208,11 +208,9 @@ } yield output_message(tree, pos)), "nodes" -> (for ((name, status) <- result.nodes) yield - JSON.Object( - "node_name" -> name.node, - "theory" -> name.theory, - "status" -> status.json, - "messages" -> + name.json + + ("status" -> status.json) + + ("messages" -> (for ((tree, pos) <- result.messages(name)) yield output_message(tree, pos))))) @@ -238,12 +236,16 @@ yield { Args(session_id, theories = theories, master_dir = master_dir, all = all) } def command(args: Args, session: Thy_Resources.Session) - : (JSON.Object.T, List[Document.Node.Name]) = + : (JSON.Object.T, (List[Document.Node.Name], List[Document.Node.Name])) = { - val purged = + val (purged, retained) = session.purge_theories( theories = args.theories, master_dir = args.master_dir, all = args.all) - (JSON.Object("purged" -> purged.map(_.node)), purged) + + val result_json = + JSON.Object("purged" -> purged.map(_.json), "retained" -> retained.map(_.json)) + + (result_json, (purged, retained)) } } }