src/Pure/PIDE/document.ML
changeset 59198 c73933e07c03
parent 59193 59f1591a11cb
child 59347 2183c731f0a7
     1.1 --- a/src/Pure/PIDE/document.ML	Mon Dec 29 19:17:24 2014 +0100
     1.2 +++ b/src/Pure/PIDE/document.ML	Mon Dec 29 20:51:42 2014 +0100
     1.3 @@ -163,6 +163,16 @@
     1.4      SOME eval => not (Command.eval_finished eval)
     1.5    | NONE => false);
     1.6  
     1.7 +fun finished_result node =
     1.8 +  (case get_result node of
     1.9 +    SOME eval => Command.eval_finished eval
    1.10 +  | NONE => false);
    1.11 +
    1.12 +fun loaded_theory name =
    1.13 +  (case try (unsuffix ".thy") name of
    1.14 +    SOME a => get_first Thy_Info.lookup_theory [a, Long_Name.base_name a]
    1.15 +  | NONE => NONE);
    1.16 +
    1.17  fun get_node nodes name = String_Graph.get_node nodes name
    1.18    handle String_Graph.UNDEF _ => empty_node;
    1.19  fun default_node name = String_Graph.default_node (name, empty_node);
    1.20 @@ -413,28 +423,31 @@
    1.21        val _ = Future.cancel delay_request;
    1.22        val delay_request' = Event_Timer.future (Time.+ (Time.now (), delay));
    1.23  
    1.24 +      fun finished_import (name, (node, _)) =
    1.25 +        finished_result node orelse is_some (loaded_theory name);
    1.26        val _ =
    1.27          nodes_of (the_version state version_id) |> String_Graph.schedule
    1.28            (fn deps => fn (name, node) =>
    1.29              if visible_node node orelse pending_result node then
    1.30                let
    1.31                  fun body () =
    1.32 -                  iterate_entries (fn (_, opt_exec) => fn () =>
    1.33 -                    (case opt_exec of
    1.34 -                      SOME exec =>
    1.35 -                        if Execution.is_running execution_id
    1.36 -                        then SOME (Command.exec execution_id exec)
    1.37 -                        else NONE
    1.38 -                    | NONE => NONE)) node ()
    1.39 -                  handle exn => if Exn.is_interrupt exn then () (*sic!*) else reraise exn;
    1.40 +                  if forall finished_import deps then
    1.41 +                    iterate_entries (fn (_, opt_exec) => fn () =>
    1.42 +                      (case opt_exec of
    1.43 +                        SOME exec =>
    1.44 +                          if Execution.is_running execution_id
    1.45 +                          then SOME (Command.exec execution_id exec)
    1.46 +                          else NONE
    1.47 +                      | NONE => NONE)) node ()
    1.48 +                  else ();
    1.49                  val future =
    1.50                    (singleton o Future.forks)
    1.51                     {name = "theory:" ^ name,
    1.52                      group = SOME (Future.new_group NONE),
    1.53 -                    deps = Future.task_of delay_request' :: maps #2 deps,
    1.54 +                    deps = Future.task_of delay_request' :: maps (the_list o #2 o #2) deps,
    1.55                      pri = 0, interrupts = false} body;
    1.56 -              in [Future.task_of future] end
    1.57 -            else []);
    1.58 +              in (node, SOME (Future.task_of future)) end
    1.59 +            else (node, NONE));
    1.60        val execution' =
    1.61          {version_id = version_id, execution_id = execution_id, delay_request = delay_request'};
    1.62      in (versions, blobs, commands, execution') end));
    1.63 @@ -478,11 +491,6 @@
    1.64          Symtab.update (a, ())) all_visible all_required
    1.65    end;
    1.66  
    1.67 -fun loaded_theory name =
    1.68 -  (case try (unsuffix ".thy") name of
    1.69 -    SOME a => get_first Thy_Info.lookup_theory [a, Long_Name.base_name a]
    1.70 -  | NONE => NONE);
    1.71 -
    1.72  fun init_theory deps node span =
    1.73    let
    1.74      val master_dir = master_directory node;