Răsfoiți Sursa

Apply @:haxe.warning rules to cached warnings too (#11775)

Rudy Ges 3 luni în urmă
părinte
comite
92941af5d7

+ 2 - 2
src/compiler/server.ml

@@ -481,8 +481,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 - 4
src/context/common.ml

@@ -22,7 +22,6 @@ open Globals
 open Lookup
 open Define
 open NativeLibraries
-open Warning
 
 type package_rule =
 	| Forbidden
@@ -265,7 +264,7 @@ type context = {
 	mutable error_ext : Error.error -> unit;
 	mutable info : ?depth:int -> ?from_macro:bool -> string -> pos -> unit;
 	mutable warning : Gctx.warning_function;
-	mutable warning_options : Warning.warning_option list list;
+	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;
@@ -352,7 +351,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 *)
@@ -1110,4 +1109,4 @@ let make_unforced_lazy t_proc f where =
 			| Error.Error e ->
 				raise (Error.Fatal_error e)
 	);
-	r
+	r

+ 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 ->
 		()

+ 1 - 1
src/context/safeCom.ml

@@ -5,7 +5,7 @@ open PlatformConfig
 type saved_warning = {
 	w_module : module_def;
 	w_warning : WarningList.warning;
-	w_options : Warning.warning_option list list;
+	w_options : warning_option list list;
 	w_msg : string;
 	w_pos : pos;
 }

+ 10 - 1
src/core/tType.ml

@@ -59,10 +59,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 lctx s ps lexbuf =
 	let fail msg p =
 		raise_typing_error msg {p with pmin = ps.pmin + p.pmin; pmax = ps.pmin + p.pmax}

+ 1 - 1
src/generators/gctx.ml

@@ -8,7 +8,7 @@ type context_main = {
 	mutable main_expr : texpr option;
 }
 
-type warning_function = ?depth:int -> ?from_macro:bool -> warning -> Warning.warning_option list list -> string -> pos -> unit
+type warning_function = ?depth:int -> ?from_macro:bool -> warning -> warning_option list list -> string -> pos -> unit
 type error_function = ?depth:int -> string -> pos -> unit
 
 type t = {