Browse Source

Apply @:haxe.warning rules to cached warnings too

Rudy Ges 11 months ago
parent
commit
6635e4efdd

+ 2 - 2
src/compiler/server.ml

@@ -478,8 +478,8 @@ let handle_cache_bound_objects com cbol =
 			Hashtbl.replace com.resources name data
 		| IncludeFile(file,position) ->
 			com.include_files <- (file,position) :: com.include_files
-		| Warning(w,msg,p) ->
-			com.warning w [] msg p
+		| Warning(w,options,msg,p) ->
+			com.warning w options msg p
 	) cbol
 
 (* Adds module [m] and all its dependencies (recursively) from the cache to the current compilation

+ 3 - 3
src/context/common.ml

@@ -379,8 +379,8 @@ type context = {
 	mutable error : ?depth:int -> string -> pos -> unit;
 	mutable error_ext : Error.error -> unit;
 	mutable info : ?depth:int -> ?from_macro:bool -> string -> pos -> unit;
-	mutable warning : ?depth:int -> ?from_macro:bool -> warning -> Warning.warning_option list list -> string -> pos -> unit;
-	mutable warning_options : Warning.warning_option list list;
+	mutable warning : ?depth:int -> ?from_macro:bool -> warning -> warning_option list list -> string -> pos -> unit;
+	mutable warning_options : warning_option list list;
 	mutable get_messages : unit -> compiler_message list;
 	mutable filter_messages : (compiler_message -> bool) -> unit;
 	mutable run_command : string -> int;
@@ -443,7 +443,7 @@ let ignore_error com =
 	b
 
 let module_warning com m w options msg p =
-	if com.display.dms_full_typing then DynArray.add m.m_extra.m_cache_bound_objects (Warning(w,msg,p));
+	if com.display.dms_full_typing then DynArray.add m.m_extra.m_cache_bound_objects (Warning(w,options,msg,p));
 	com.warning w options msg p
 
 (* Defines *)

+ 3 - 5
src/context/display/deprecationCheck.ml

@@ -22,11 +22,9 @@ let warned_positions = Hashtbl.create 0
 let warn_deprecation dctx s p_usage =
 	let pkey p = (p.pfile,p.pmin) in
 	if not (Hashtbl.mem warned_positions (pkey p_usage)) then begin
-		Hashtbl.add warned_positions (pkey p_usage) (s,p_usage);
-		if not (is_diagnostics dctx.com) then begin
-			let options = Warning.from_meta (dctx.class_meta @ dctx.field_meta) in
-			module_warning dctx.com dctx.curmod WDeprecated options s p_usage;
-		end
+		let options = Warning.from_meta (dctx.class_meta @ dctx.field_meta) in
+		Hashtbl.add warned_positions (pkey p_usage) (s,p_usage,options);
+		module_warning dctx.com dctx.curmod WDeprecated options s p_usage;
 	end
 
 let print_deprecation_message dctx meta s p_usage =

+ 7 - 3
src/context/display/diagnosticsPrinter.ml

@@ -183,9 +183,13 @@ let json_of_diagnostics com dctx =
 	(* non-append from here *)
 	begin match Warning.get_mode WDeprecated com.warning_options with
 	| WMEnable ->
-		Hashtbl.iter (fun _ (s,p) ->
-			let wobj = Warning.warning_obj WDeprecated in
-			add DKDeprecationWarning p MessageSeverity.Warning (Some wobj.w_name) (JString s);
+		Hashtbl.iter (fun _ (s,p,options) ->
+			begin match Warning.get_mode WDeprecated (com.warning_options @ options) with
+			| WMEnable ->
+				let wobj = Warning.warning_obj WDeprecated in
+				add DKDeprecationWarning p MessageSeverity.Warning (Some wobj.w_name) (JString s);
+			| WMDisable -> ()
+			end
 		) DeprecationCheck.warned_positions;
 	| WMDisable ->
 		()

+ 10 - 1
src/core/tType.ml

@@ -56,10 +56,19 @@ type type_param_host =
 	| TPHLocal
 	| TPHUnbound
 
+type warning_mode =
+	| WMEnable
+	| WMDisable
+
+type warning_option = {
+	wo_warning : WarningList.warning;
+	wo_mode : warning_mode;
+}
+
 type cache_bound_object =
 	| Resource of string * string
 	| IncludeFile of string * string
-	| Warning of WarningList.warning * string * pos
+	| Warning of WarningList.warning * (warning_option list list) * string * pos
 
 type t =
 	| TMono of tmono

+ 1 - 9
src/core/warning.ml

@@ -1,16 +1,8 @@
 open Globals
 open Error
+open TType
 include WarningList
 
-type warning_mode =
-	| WMEnable
-	| WMDisable
-
-type warning_option = {
-	wo_warning : warning;
-	wo_mode : warning_mode;
-}
-
 let parse_options s ps lexbuf =
 	let fail msg p =
 		raise_typing_error msg {p with pmin = ps.pmin + p.pmin; pmax = ps.pmin + p.pmax}