src/Pure/PIDE/document.ML
changeset 52514 8dd8ab81f1d7
parent 52513 04210c1bcb90
child 52515 0dcadc90550b
equal deleted inserted replaced
52513:04210c1bcb90 52514:8dd8ab81f1d7
   435       let val last = Entries.get_after (get_entries node) common
   435       let val last = Entries.get_after (get_entries node) common
   436       in (last, update_flags last flags) end
   436       in (last, update_flags last flags) end
   437     else (common, flags)
   437     else (common, flags)
   438   end;
   438   end;
   439 
   439 
   440 fun illegal_init _ = error "Illegal theory header after end of theory";
       
   441 
       
   442 fun new_exec state proper_init command_id' (execs, command_exec, init) =
   440 fun new_exec state proper_init command_id' (execs, command_exec, init) =
   443   if not proper_init andalso is_none init then NONE
   441   if not proper_init andalso is_none init then NONE
   444   else
   442   else
   445     let
   443     let
   446       val (name, span) = the_command state command_id' ||> Lazy.force;
   444       val (name, span) = the_command state command_id' ||> Lazy.force;
       
   445       fun illegal_init _ = error "Illegal theory header after end of theory";
   447       val (modify_init, init') =
   446       val (modify_init, init') =
   448         if Keyword.is_theory_begin name then
   447         if Keyword.is_theory_begin name then
   449           (Toplevel.modify_init (fn () => the_default illegal_init init span), NONE)
   448           (Toplevel.modify_init (fn () => the_default illegal_init init span), NONE)
   450         else (I, init);
   449         else (I, init);
   451       val exec_id' = new_id ();
   450       val exec_id' = new_id ();
   486               deps = map (Future.task_of o #2) deps, pri = 0, interrupts = false}
   485               deps = map (Future.task_of o #2) deps, pri = 0, interrupts = false}
   487             (fn () =>
   486             (fn () =>
   488               let
   487               let
   489                 val imports = map (apsnd Future.join) deps;
   488                 val imports = map (apsnd Future.join) deps;
   490                 val updated_imports = exists (is_some o #3 o #1 o #2) imports;
   489                 val updated_imports = exists (is_some o #3 o #1 o #2) imports;
   491                 val required = is_required name;
   490                 val node_required = is_required name;
   492               in
   491               in
   493                 if updated_imports orelse AList.defined (op =) edits name orelse
   492                 if updated_imports orelse AList.defined (op =) edits name orelse
   494                   not (stable_entries node) orelse not (finished_theory node)
   493                   not (stable_entries node) orelse not (finished_theory node)
   495                 then
   494                 then
   496                   let
   495                   let
   499                     val proper_init =
   498                     val proper_init =
   500                       check_theory false name node andalso
   499                       check_theory false name node andalso
   501                       forall (fn (name, (_, node)) => check_theory true name node) imports;
   500                       forall (fn (name, (_, node)) => check_theory true name node) imports;
   502 
   501 
   503                     val last_visible = visible_last node;
   502                     val last_visible = visible_last node;
   504                     val (common, (visible, initial)) =
   503                     val (common, (still_visible, initial)) =
   505                       if updated_imports then (NONE, (true, true))
   504                       if updated_imports then (NONE, (true, true))
   506                       else last_common state last_visible node0 node;
   505                       else last_common state last_visible node0 node;
   507                     val common_command_exec = the_default_entry node common;
   506                     val common_command_exec = the_default_entry node common;
   508 
   507 
   509                     val (new_execs, (command_id', (_, exec')), _) =
   508                     val (new_execs, (command_id', (_, exec')), _) =
   510                       ([], common_command_exec, if initial then SOME init else NONE) |>
   509                       ([], common_command_exec, if initial then SOME init else NONE) |>
   511                       (visible orelse required) ?
   510                       (still_visible orelse node_required) ?
   512                         iterate_entries_after common
   511                         iterate_entries_after common
   513                           (fn ((prev, id), _) => fn res =>
   512                           (fn ((prev, id), _) => fn res =>
   514                             if not required andalso prev = last_visible then NONE
   513                             if not node_required andalso prev = last_visible then NONE
   515                             else new_exec state proper_init id res) node;
   514                             else new_exec state proper_init id res) node;
   516 
   515 
   517                     val no_execs =
   516                     val no_execs =
   518                       iterate_entries_after common
   517                       iterate_entries_after common
   519                         (fn ((_, id0), exec0) => fn res =>
   518                         (fn ((_, id0), exec0) => fn res =>