Browse Source

[server] reverted module recaching on display requests (#8596)

Aleksandr Kuzmenko 6 years ago
parent
commit
725260634d
3 changed files with 7 additions and 33 deletions
  1. 2 22
      src/compiler/server.ml
  2. 0 11
      src/context/compilationServer.ml
  3. 5 0
      tests/server/src/Main.hx

+ 2 - 22
src/compiler/server.ml

@@ -184,8 +184,6 @@ module ServerCompilationContext = struct
 		mutable compilation_mark : int;
 		(* A list of delays which are run after compilation *)
 		mutable delays : (unit -> unit) list;
-		(* A list of modules which were (perhaps temporarily) removed from the cache *)
-		mutable removed_modules : (context_cache * path * module_def) list;
 		(* True if it's an actual compilation, false if it's a display operation *)
 		mutable was_compilation : bool;
 	}
@@ -199,7 +197,6 @@ module ServerCompilationContext = struct
 		compilation_mark = 0;
 		mark_loop = 0;
 		delays = [];
-		removed_modules = [];
 		was_compilation = false;
 	}
 
@@ -211,9 +208,6 @@ module ServerCompilationContext = struct
 		sctx.delays <- [];
 		List.iter (fun f -> f()) fl
 
-	let is_removed_module sctx m =
-		List.exists (fun (_,_,m') -> m == m') sctx.removed_modules
-
 	let reset sctx =
 		Hashtbl.clear sctx.changed_directories;
 		sctx.was_compilation <- false
@@ -418,8 +412,6 @@ let add_modules sctx ctx m p =
 			| MCode, MMacro | MMacro, MCode ->
 				(* this was just a dependency to check : do not add to the context *)
 				PMap.iter (Hashtbl.replace com.resources) m.m_extra.m_binded_res;
-			| _ when is_removed_module sctx m ->
-				()
 			| _ ->
 				ServerMessage.reusing com tabs m;
 				m.m_extra.m_added <- sctx.compilation_step;
@@ -477,22 +469,11 @@ let type_module sctx (ctx:Typecore.typer) mpath p =
 (* Sets up the per-compilation context. *)
 let create sctx write params =
 	let cs = sctx.cs in
-	let recache_removed_modules () =
-		List.iter (fun (cc,k,m) ->
-			try
-				ignore(cc#find_module k);
-			with Not_found ->
-				cc#cache_module k m
-		) sctx.removed_modules;
-		sctx.removed_modules <- []
-	in
 	let maybe_cache_context com =
 		if com.display.dms_full_typing then begin
 			CommonCache.cache_context sctx.cs com;
 			ServerMessage.cached_modules com "" (List.length com.modules);
-			sctx.removed_modules <- [];
-		end else
-			recache_removed_modules ()
+		end
 	in
 	let ctx = create_context params in
 	ctx.flush <- (fun() ->
@@ -524,8 +505,7 @@ let create sctx write params =
 			let file = (DisplayPosition.display_position#get).pfile in
 			(* force parsing again : if the completion point have been changed *)
 			cs#remove_files file;
-			sctx.removed_modules <- cs#filter_modules file;
-			add_delay sctx recache_removed_modules;
+			cs#taint_modules file;
 		end;
 		try
 			if (Hashtbl.find sctx.class_paths sign) <> ctx.com.class_path then begin

+ 0 - 11
src/context/compilationServer.ml

@@ -145,17 +145,6 @@ class cache = object(self)
 			) cc#get_modules
 		) contexts
 
-	method filter_modules file =
-		let removed = DynArray.create () in
-		(* TODO: Using filter_map_inplace would be better, but we can't move to OCaml 4.03 yet *)
-		Hashtbl.iter (fun _ cc ->
-			Hashtbl.iter (fun k m ->
-				if m.m_extra.m_file = file then DynArray.add removed (cc,k,m);
-			) cc#get_modules
-		) contexts;
-		DynArray.iter (fun (cc,k,_) -> Hashtbl.remove cc#get_modules k) removed;
-		DynArray.to_list removed
-
 	(* haxelibs *)
 
 	method find_haxelib key =

+ 5 - 0
tests/server/src/Main.hx

@@ -104,6 +104,8 @@ class ServerTests extends HaxeServerTestCase {
 		assertSuccess();
 	}
 
+
+	#if false // @see https://github.com/HaxeFoundation/haxe/issues/8596#issuecomment-518815594
 	function testDisplayModuleRecache() {
 		vfs.putContent("HelloWorld.hx", getTemplate("HelloWorld.hx"));
 		var args = ["--main", "HelloWorld", "--interp"];
@@ -124,7 +126,9 @@ class ServerTests extends HaxeServerTestCase {
 		runHaxe(args);
 		assertSkipping("HelloWorld");
 	}
+	#end
 
+	#if false // @see https://github.com/HaxeFoundation/haxe/issues/8596#issuecomment-518815594
 	function testMutuallyDependent() {
 		vfs.putContent("MutuallyDependent1.hx", getTemplate("MutuallyDependent1.hx"));
 		vfs.putContent("MutuallyDependent2.hx", getTemplate("MutuallyDependent2.hx"));
@@ -136,6 +140,7 @@ class ServerTests extends HaxeServerTestCase {
 		runHaxe(args);
 		assertSuccess();
 	}
+	#end
 
 	function testSyntaxCache() {
 		vfs.putContent("HelloWorld.hx", getTemplate("HelloWorld.hx"));