Bläddra i källkod

[server] turn module_tainting_reason into a type

Simon Krajewski 1 år sedan
förälder
incheckning
eb3d93643e

+ 1 - 1
src/context/display/displayJson.ml

@@ -378,7 +378,7 @@ let handler =
 			let file = hctx.jsonrpc#get_string_param "file" in
 			let fkey = hctx.com.file_keys#get file in
 			let cs = hctx.display#get_cs in
-			cs#taint_modules fkey "server/invalidate";
+			cs#taint_modules fkey ServerInvalidate;
 			cs#remove_files fkey;
 			hctx.send_result jnull
 		);

+ 1 - 1
src/context/display/displayTexpr.ml

@@ -178,7 +178,7 @@ let check_display_file ctx cs =
 			let fkey = DisplayPosition.display_position#get_file_key in
 			(* force parsing again : if the completion point have been changed *)
 			cs#remove_files fkey;
-			cs#taint_modules fkey "check_display_file";
+			cs#taint_modules fkey CheckDisplayFile;
 		end
 	| None ->
 		()

+ 6 - 1
src/core/tPrinting.ml

@@ -610,11 +610,16 @@ module Printer = struct
 		| MExtern -> "MExtern"
 		| MImport -> "MImport"
 
+	let s_module_tainting_reason = function
+		| CheckDisplayFile -> "check_display_file"
+		| ServerInvalidate -> "server/invalidate"
+		| ServerInvalidateFiles -> "server_invalidate_files"
+
 	let s_module_skip_reason reason =
 		let rec loop stack = function
 			| DependencyDirty(path,reason) ->
 				(Printf.sprintf "%s%s - %s" (if stack = [] then "DependencyDirty " else "") (s_type_path path) (if List.mem path stack then "rec" else loop (path :: stack) reason))
-			| Tainted cause -> "Tainted " ^ cause
+			| Tainted cause -> "Tainted " ^ (s_module_tainting_reason cause)
 			| FileChanged file -> "FileChanged " ^ file
 			| Shadowed file -> "Shadowed " ^ file
 			| LibraryChanged -> "LibraryChanged"

+ 6 - 1
src/core/tType.ml

@@ -32,9 +32,14 @@ type module_check_policy =
 	| NoCheckShadowing
 	| Retype
 
+type module_tainting_reason =
+	| CheckDisplayFile
+	| ServerInvalidate
+	| ServerInvalidateFiles
+
 type module_skip_reason =
 	| DependencyDirty of path * module_skip_reason
-	| Tainted of string
+	| Tainted of module_tainting_reason
 	| FileChanged of string
 	| Shadowed of string
 	| LibraryChanged

+ 0 - 1
src/generators/jsSourcemap.ml

@@ -18,7 +18,6 @@
  *)
 open Extlib_leftovers
 open Globals
-open Ast
 open Type
 open Common
 

+ 2 - 2
src/macro/macroApi.ml

@@ -2276,7 +2276,7 @@ let macro_api ccom get_api =
 				let c = match t with
 					| TInst(c,_) -> c
 					| _ -> die "" __LOC__
-				in				
+				in
 				mk_type_param c TPHType default None
 			) (decode_array tpl) in
 			let rec map t = match t with
@@ -2318,7 +2318,7 @@ let macro_api ccom get_api =
 			List.iter (fun v ->
 				let s = decode_string v in
 				let s = com.file_keys#get s in
-				cs#taint_modules s "server_invalidate_files";
+				cs#taint_modules s ServerInvalidateFiles;
 				cs#remove_files s;
 			) (decode_array a);
 			vnull

+ 1 - 1
tests/server/src/cases/issues/Issue9690.hx

@@ -15,4 +15,4 @@ class Issue9690 extends TestCase {
 		Assert.isTrue(lastResult.hasError);
 		Assert.isTrue(lastResult.stderr.contains('Error: side effect!'));
 	}
-}
+}

+ 1 - 0
tests/unit/src/unit/TestOverloads.hx

@@ -2,6 +2,7 @@ package unit;
 import haxe.io.Bytes;
 import unit.HelperMacros.typeError;
 import unit.HelperMacros.typedAs;
+
 using unit.TestOverloads.UsingTest2;
 using unit.TestOverloads.UsingTest3;