瀏覽代碼

[display] change server/moduleCreated implementation

Simon Krajewski 6 年之前
父節點
當前提交
ec8458a392
共有 2 個文件被更改,包括 19 次插入4 次删除
  1. 5 4
      src/context/display/displayJson.ml
  2. 14 0
      tests/server/src/Main.hx

+ 5 - 4
src/context/display/displayJson.ml

@@ -182,10 +182,11 @@ let handler =
 		"server/moduleCreated", (fun hctx ->
 			let file = hctx.jsonrpc#get_string_param "file" in
 			let file = Path.unique_full_path file in
-			hctx.com.callbacks#add_after_init_macros (fun () ->
-				ignore(TypeloadParse.parse_module_file hctx.com file null_pos);
-				hctx.send_result (jstring file);
-			);
+			let cs = hctx.display#get_cs in
+			List.iter (fun (sign,_) ->
+				Hashtbl.replace cs.cache.c_removed_files (file,sign) ()
+			) (CompilationServer.get_signs cs);
+			hctx.send_result (jstring file);
 		);
 		"server/files", (fun hctx ->
 			let sign = Digest.from_hex (hctx.jsonrpc#get_string_param "signature") in

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

@@ -166,6 +166,20 @@ class ServerTests extends HaxeServerTestCase {
 		});
 	}
 
+	function testSyntaxCache2() {
+		vfs.putContent("HelloWorld.hx", getTemplate("HelloWorld.hx"));
+		var args = ["-cp", ".", "--interp"];
+		runHaxeJson(args, ServerMethods.ReadClassPaths, null);
+		vfs.putContent("Empty.hx", getTemplate("Empty.hx"));
+		runHaxeJson([] /* No args here because file watchers don't generally know */, ServerMethods.ModuleCreated, {file: new FsPath("Empty.hx")});
+		runHaxeJson(args, DisplayMethods.Completion, {file: new FsPath("HelloWorld.hx"), offset: 75, wasAutoTriggered: false});
+		var completion = parseCompletion();
+		assertHasCompletion(completion, module -> switch (module.kind) {
+			case Type: module.args.path.typeName == "Empty";
+			case _: false;
+		});
+	}
+
 	function testVectorInliner() {
 		vfs.putContent("Vector.hx", getTemplate("Vector.hx"));
 		vfs.putContent("VectorInliner.hx", getTemplate("VectorInliner.hx"));