فهرست منبع

clean up diagnostics handling (closes #5606)

Simon Krajewski 9 سال پیش
والد
کامیت
e32a1b22c3
4فایلهای تغییر یافته به همراه11 افزوده شده و 29 حذف شده
  1. 6 3
      src/display/display.ml
  2. 3 3
      src/main.ml
  3. 2 2
      src/typing/common.ml
  4. 0 21
      src/typing/typeload.ml

+ 6 - 3
src/display/display.ml

@@ -436,9 +436,9 @@ module Diagnostics = struct
 			find_unused_variables com e;
 			check_other_things com e
 
-	let prepare com =
+	let prepare com global =
 		List.iter (function
-			| TClassDecl c ->
+			| TClassDecl c when global || is_display_file c.cl_pos.pfile ->
 				List.iter (prepare_field com) c.cl_ordered_fields;
 				List.iter (prepare_field com) c.cl_ordered_statics;
 				(match c.cl_constructor with None -> () | Some cf -> prepare_field com cf);
@@ -446,7 +446,7 @@ module Diagnostics = struct
 				()
 		) com.types
 
-	let print_diagnostics ctx =
+	let print_diagnostics ctx global =
 		let com = ctx.com in
 		let diag = Hashtbl.create 0 in
 		let add dk p sev args =
@@ -460,6 +460,9 @@ module Diagnostics = struct
 			in
 			DynArray.add diag (dk,p,sev,args)
 		in
+		let add dk p sev args =
+			if global || is_display_file p.pfile then add dk p sev args
+		in
 		let find_type i =
 			let types = ref [] in
 			Hashtbl.iter (fun _ m ->

+ 3 - 3
src/main.ml

@@ -1611,9 +1611,9 @@ try
 					if c <> 0 then c else compare p1.pmin p2.pmin
 				) usages in
 				raise (Display.DisplayPosition usages)
-			| DMDiagnostics true ->
-				Display.Diagnostics.prepare com;
-				raise (Display.Diagnostics (Display.Diagnostics.print_diagnostics tctx))
+			| DMDiagnostics global ->
+				Display.Diagnostics.prepare com global;
+				raise (Display.Diagnostics (Display.Diagnostics.print_diagnostics tctx global))
 			| DMStatistics ->
 				let stats = Display.Statistics.collect_statistics tctx in
 				raise (Display.Statistics (Display.StatisticsPrinter.print_statistics stats))

+ 2 - 2
src/typing/common.ml

@@ -173,13 +173,13 @@ module DisplayMode = struct
 				dms_exit_during_typing = false;
 				dms_force_macro_typing = true;
 			}
-		| DMDiagnostics _ -> { settings with
+		| DMDiagnostics global -> { settings with
 				dms_full_typing = true;
 				dms_error_policy = EPCollect;
 				dms_is_diagnostics_run = true;
 				dms_collect_data = true;
 				dms_inline = false;
-				dms_display_file_policy = DFPAlso;
+				dms_display_file_policy = if global then DFPNo else DFPAlso;
 				dms_exit_during_typing = false;
 			}
 		| DMStatistics -> { settings with

+ 0 - 21
src/typing/typeload.ml

@@ -3536,27 +3536,6 @@ let type_module ctx mpath file ?(is_extern=false) tdecls p =
 	let ctx = type_types_into_module ctx m tdecls p in
 	if is_extern then m.m_extra.m_kind <- MExtern;
 	begin if ctx.is_display_file then match ctx.com.display.dms_kind with
-		| DMDiagnostics false ->
-			flush_pass ctx PBuildClass "diagnostics";
-			List.iter (fun mt -> match mt with
-				| TClassDecl c | TAbstractDecl({a_impl = Some c}) ->
-					ignore(c.cl_build());
-					let field cf =
-						begin match cf.cf_kind with
-						| Method MethMacro ->
-							(try ignore (ctx.g.do_macro ctx MDisplay c.cl_path cf.cf_name [] p) with Exit -> ())
-						| _ ->
-							ignore(follow cf.cf_type);
-						end;
-						Display.Diagnostics.prepare_field ctx.com cf;
-					in
-					List.iter field c.cl_ordered_fields;
-					List.iter field c.cl_ordered_statics;
-					(match c.cl_constructor with None -> () | Some cf -> field cf);
-				| _ ->
-					()
-			) m.m_types;
-			raise (Display.Diagnostics (Display.Diagnostics.print_diagnostics ctx))
 		| DMResolve s ->
 			resolve_position_by_path ctx {tname = s; tpackage = []; tsub = None; tparams = []} p
 		| _ ->