tuned error -- allow user to click on hyperlink to open remote file;
authorwenzelm
Thu, 10 Apr 2014 10:27:29 +0200
changeset 56504 d71f4be7e287
parent 56503 9e23fafe4037
child 56505 aed94b61f65b
tuned error -- allow user to click on hyperlink to open remote file;
src/Pure/PIDE/command.ML
--- a/src/Pure/PIDE/command.ML	Thu Apr 10 10:06:54 2014 +0200
+++ b/src/Pure/PIDE/command.ML	Thu Apr 10 10:27:29 2014 +0200
@@ -89,9 +89,17 @@
 type blob =
   (string * (SHA1.digest * string list) option) Exn.result;  (*file node name, digest, lines*)
 
-fun read_file master_dir pos src_path =
+fun read_file_node file_node master_dir pos src_path =
   let
     val _ = Position.report pos Markup.language_path;
+    val _ =
+      (case try Url.explode file_node of
+        NONE => ()
+      | SOME (Url.File _) => ()
+      | _ =>
+         (Position.report pos (Markup.path file_node);
+          error ("Prover cannot load remote file " ^
+            Markup.markup (Markup.path file_node) (quote file_node) ^ Position.here pos)));
     val full_path = File.check_file (File.full_path master_dir src_path);
     val _ = Position.report pos (Markup.path (Path.implode full_path));
     val text = File.read full_path;
@@ -99,6 +107,8 @@
     val digest = SHA1.digest text;
   in {src_path = src_path, lines = lines, digest = digest, pos = Path.position full_path} end;
 
+val read_file = read_file_node "";
+
 local
 
 fun blob_file src_path lines digest file_node =
@@ -115,8 +125,9 @@
     [span] => span
       |> Thy_Syntax.resolve_files (fn cmd => fn (path, pos) =>
         let
-          fun make_file src_path (Exn.Res (_, NONE)) =
-                Exn.interruptible_capture (fn () => read_file master_dir pos src_path) ()
+          fun make_file src_path (Exn.Res (file_node, NONE)) =
+                Exn.interruptible_capture (fn () =>
+                  read_file_node file_node master_dir pos src_path) ()
             | make_file src_path (Exn.Res (file_node, SOME (digest, lines))) =
                (Position.reports [(pos, Markup.language_path), (pos, Markup.path file_node)];
                 Exn.Res (blob_file src_path lines digest file_node))