Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 2cfa1e3d authored by MARCHE Claude's avatar MARCHE Claude
Browse files

in case of syntax error on reload, do not exit abruptly but displays a message...

in case of syntax error on reload, do not exit abruptly but displays a message and scroll to loc of the error
parent f482a3d6
...@@ -445,8 +445,8 @@ install_local: bin/why3config ...@@ -445,8 +445,8 @@ install_local: bin/why3config
ifeq (@enable_ide@,yes) ifeq (@enable_ide@,yes)
IDE_FILES = xml session gconfig db gmain # IDE_FILES = xml session gconfig db gmain
# IDE_FILES = xml session gconfig newmain IDE_FILES = xml session gconfig newmain
IDEMODULES = $(addprefix src/ide/, $(IDE_FILES)) IDEMODULES = $(addprefix src/ide/, $(IDE_FILES))
......
...@@ -508,13 +508,9 @@ let () = ...@@ -508,13 +508,9 @@ let () =
M.maximum_running_proofs := gconfig.max_running_processes; M.maximum_running_proofs := gconfig.max_running_processes;
eprintf " done@." eprintf " done@."
with e -> with e ->
eprintf "Error while opening session with database '%s'@." project_dir; eprintf "@[Error while opening session:@ %a@.@]"
eprintf "Aborting...@."; Exn_printer.exn_printer e;
raise e exit 1
let info_window ?(callback=(fun () -> ())) mt s = let info_window ?(callback=(fun () -> ())) mt s =
...@@ -1051,18 +1047,20 @@ let color_loc (v:GSourceView2.source_view) l b e = ...@@ -1051,18 +1047,20 @@ let color_loc (v:GSourceView2.source_view) l b e =
let stop = start#forward_chars (e-b) in let stop = start#forward_chars (e-b) in
buf#apply_tag ~start ~stop orange_bg buf#apply_tag ~start ~stop orange_bg
let scroll_to_loc loc =
let (f,l,b,e) = Loc.get loc in
if f <> !current_file then
begin
source_view#source_buffer#set_text (source_text f);
set_current_file f;
end;
move_to_line source_view (l-1);
erase_color_loc source_view;
color_loc source_view l b e
let scroll_to_id id = let scroll_to_id id =
match id.Ident.id_loc with match id.Ident.id_loc with
| Some loc -> | Some loc -> scroll_to_loc loc
let (f,l,b,e) = Loc.get loc in
if f <> !current_file then
begin
source_view#source_buffer#set_text (source_text f);
set_current_file f;
end;
move_to_line source_view (l-1);
erase_color_loc source_view;
color_loc source_view l b e
| None -> | None ->
source_view#source_buffer#set_text source_view#source_buffer#set_text
"Non-localized ident (no position available)\n"; "Non-localized ident (no position available)\n";
...@@ -1190,6 +1188,24 @@ let () = ...@@ -1190,6 +1188,24 @@ let () =
b#connect#pressed ~callback:replay_obsolete_proofs b#connect#pressed ~callback:replay_obsolete_proofs
in () in ()
let reload () =
try
M.reload_all gconfig.provers;
current_file := ""
with
| Loc.Located(loc,Parsing.Parse_error) ->
fprintf str_formatter
"@[Syntax error:@ %a@]" Loc.gen_report_position loc;
let msg = flush_str_formatter () in
scroll_to_loc loc;
info_window `ERROR msg
| e ->
fprintf str_formatter
"@[Error while reading file:@ %a@]" Exn_printer.exn_printer e;
let msg = flush_str_formatter () in
info_window `ERROR msg
let () = let () =
let b = GButton.button ~packing:tools_box#add ~label:"Reload" () in let b = GButton.button ~packing:tools_box#add ~label:"Reload" () in
b#misc#set_tooltip_markup "Reloads the files"; b#misc#set_tooltip_markup "Reloads the files";
...@@ -1197,9 +1213,7 @@ let () = ...@@ -1197,9 +1213,7 @@ let () =
let i = GMisc.image ~pixbuf:(!image_reload) () in let i = GMisc.image ~pixbuf:(!image_reload) () in
let () = b#set_image i#coerce in let () = b#set_image i#coerce in
let (_ : GtkSignal.id) = let (_ : GtkSignal.id) =
b#connect#pressed ~callback:(fun () -> b#connect#pressed ~callback:reload
current_file := "";
M.reload_all gconfig.provers)
in () in ()
(*************) (*************)
......
...@@ -862,9 +862,6 @@ let reload_root_goal ~provers mth tname old_goals t : goal = ...@@ -862,9 +862,6 @@ let reload_root_goal ~provers mth tname old_goals t : goal =
let id = (Task.task_goal t).Decl.pr_name in let id = (Task.task_goal t).Decl.pr_name in
let gname = id.Ident.id_string in let gname = id.Ident.id_string in
let sum = task_checksum t in let sum = task_checksum t in
(*
let goal = raw_add_goal (Parent_theory mth) gname expl sum (Some t) in
*)
let old_goal, goal_obsolete = let old_goal, goal_obsolete =
try try
let old_goal = Util.Mstr.find gname old_goals in let old_goal = Util.Mstr.find gname old_goals in
...@@ -903,7 +900,8 @@ let reload_theory ~provers mfile old_theories (_,tname,th) = ...@@ -903,7 +900,8 @@ let reload_theory ~provers mfile old_theories (_,tname,th) =
(* reloads a file *) (* reloads a file *)
let reload_file ~provers mf = let reload_file ~provers mf theories =
(*
eprintf "[Reload] file '%s'@." mf.file_name; eprintf "[Reload] file '%s'@." mf.file_name;
let theories = let theories =
try try
...@@ -914,6 +912,7 @@ let reload_file ~provers mf = ...@@ -914,6 +912,7 @@ let reload_file ~provers mf =
(* TODO: do something clever than that! *) (* TODO: do something clever than that! *)
exit 1 exit 1
in in
*)
let new_mf = raw_add_file mf.file_name in let new_mf = raw_add_file mf.file_name in
let old_theories = List.fold_left let old_theories = List.fold_left
(fun acc t -> Util.Mstr.add t.theory_name t acc) (fun acc t -> Util.Mstr.add t.theory_name t acc)
...@@ -931,9 +930,15 @@ let reload_file ~provers mf = ...@@ -931,9 +930,15 @@ let reload_file ~provers mf =
(* reloads all files *) (* reloads all files *)
let reload_all provers = let reload_all provers =
let files = !all_files in let files = !all_files in
let all_theories =
List.map (fun mf ->
eprintf "[Reload] file '%s'@." mf.file_name;
(mf,read_file mf.file_name))
files
in
all_files := []; all_files := [];
O.reset (); O.reset ();
List.iter (reload_file ~provers) files List.iter (fun (mf,ths) -> reload_file ~provers mf ths) all_theories
(****************************) (****************************)
(* session opening *) (* session opening *)
......
...@@ -223,8 +223,9 @@ module Make(O: OBSERVER) : sig ...@@ -223,8 +223,9 @@ module Make(O: OBSERVER) : sig
val reload_all: prover_data Util.Mstr.t -> unit val reload_all: prover_data Util.Mstr.t -> unit
(** reloads all the files (** reloads all the files
If for a given file, the parsing or typing fails, then If for one of the file, the parsing or typing fails, then
then old version is kept, but marked obsolete the complete old session state is kept, and an exception
is raised
*) *)
(* (*
TODO TODO
......
...@@ -16,7 +16,7 @@ theory TestInt ...@@ -16,7 +16,7 @@ theory TestInt
use import int.Int use import int.Int
goal Test1: 2+2 = 5 goal Test1: 2+2 =
goal Test2: forall x:int. x*x >= 0 goal Test2: forall x:int. x*x >= 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment