Преглед изворни кода

[display] let's try diagnostics caching again

Simon Krajewski пре 7 година
родитељ
комит
b7376e1381
4 измењених фајлова са 11 додато и 5 уклоњено
  1. 1 1
      src/compiler/displayOutput.ml
  2. 5 3
      src/context/compilationServer.ml
  3. 3 1
      src/context/typecore.ml
  4. 2 0
      src/core/type.ml

+ 1 - 1
src/compiler/displayOutput.ml

@@ -609,7 +609,7 @@ let process_global_display_mode com tctx = match com.display.dms_kind with
 		FindReferences.find_references tctx com with_definition
 	| DMDiagnostics global ->
 		let dctx = Diagnostics.prepare com global in
-		(* Option.may (fun cs -> CompilationServer.cache_context cs com) (CompilationServer.get()); *)
+		Option.may (fun cs -> CompilationServer.cache_context cs com) (CompilationServer.get());
 		raise_diagnostics (Diagnostics.Printer.print_diagnostics dctx tctx global)
 	| DMStatistics ->
 		let stats = Statistics.collect_statistics tctx None in

+ 5 - 3
src/context/compilationServer.ml

@@ -184,9 +184,11 @@ let clear_directories cs key =
 
 let rec cache_context cs com =
 	let cache_module m =
-		cache_module cs (m.m_path,m.m_extra.m_sign) m;
+		if not m.m_extra.m_has_error then
+			cache_module cs (m.m_path,m.m_extra.m_sign) m;
 	in
 	List.iter cache_module com.modules;
-	match com.get_macros() with
+	begin match com.get_macros() with
 	| None -> ()
-	| Some com -> cache_context cs com
+	| Some com -> cache_context cs com
+	end

+ 3 - 1
src/context/typecore.ml

@@ -151,7 +151,9 @@ let pass_name = function
 
 let display_error ctx msg p = match ctx.com.display.DisplayMode.dms_error_policy with
 	| DisplayMode.EPShow | DisplayMode.EPIgnore -> ctx.on_error ctx msg p
-	| DisplayMode.EPCollect -> add_diagnostics_message ctx.com msg p DisplayTypes.DiagnosticsSeverity.Error
+	| DisplayMode.EPCollect ->
+		ctx.m.curmod.m_extra.m_has_error <- true;
+		add_diagnostics_message ctx.com msg p DisplayTypes.DiagnosticsSeverity.Error
 
 let make_call ctx e el t p = (!make_call_ref) ctx e el t p
 

+ 2 - 0
src/core/type.ml

@@ -329,6 +329,7 @@ and module_def_extra = {
 	mutable m_reuse_macro_calls : string list;
 	mutable m_if_feature : (string *(tclass * tclass_field * bool)) list;
 	mutable m_features : (string,bool) Hashtbl.t;
+	mutable m_has_error : bool;
 }
 
 and module_kind =
@@ -488,6 +489,7 @@ let module_extra file sign time kind policy =
 		m_if_feature = [];
 		m_features = Hashtbl.create 0;
 		m_check_policy = policy;
+		m_has_error = false;
 	}