浏览代码

[server] don't skip mtime checks for non-hx files

see #8748
Simon Krajewski 6 年之前
父节点
当前提交
8b49469316
共有 2 个文件被更改,包括 28 次插入4 次删除
  1. 1 1
      src/compiler/server.ml
  2. 27 3
      tests/server/src/Main.hx

+ 1 - 1
src/compiler/server.ml

@@ -394,7 +394,7 @@ let check_module sctx ctx m p =
 				m.m_extra.m_mark <- mark;
 				if old_mark <= start_mark then begin
 					if not (has_policy NoCheckShadowing) then check_module_path();
-					if not (has_policy NoCheckFileTimeModification) then check_file();
+					if not (has_policy NoCheckFileTimeModification) || file_extension m.m_extra.m_file <> "hx" then check_file();
 				end;
 				if not (has_policy NoCheckDependencies) then check_dependencies();
 				None

+ 27 - 3
tests/server/src/Main.hx

@@ -1,8 +1,10 @@
-using StringTools;
-
 import haxe.display.Display;
 import haxe.display.FsPath;
 import haxe.display.Server;
+import utest.Assert;
+
+using StringTools;
+using Lambda;
 
 @:timeout(10000)
 class ServerTests extends HaxeServerTestCase {
@@ -226,11 +228,33 @@ class ServerTests extends HaxeServerTestCase {
 		assertSuccess();
 		vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main2.hx"));
 		runHaxe(args);
-		assertErrorMessage("Main.hx:8: characters 3-21 : Cannot force inline-call to test because it is overridden");
+		assertErrorMessage("Cannot force inline-call to test because it is overridden");
 		vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main3.hx"));
 		runHaxe(args);
 		assertSuccess();
 	}
+
+	function testIssue8748() {
+		vfs.putContent("Dependency.hx", getTemplate("Dependency.hx"));
+		vfs.putContent("WithDependency.hx", getTemplate("WithDependency.hx"));
+		vfs.putContent("res/dep.dep", "");
+		var args = [
+			"-main",
+			"WithDependency",
+			"--interp",
+			"--macro",
+			"haxe.macro.Context.registerModuleDependency(\"Dependency\", \"res/dep.dep\")"
+		];
+		runHaxeJson(args, ServerMethods.Configure, {noModuleChecks: true});
+		runHaxe(args);
+		runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("WithDependency.hx"), offset: 65});
+		assertReuse("Dependency");
+		vfs.touchFile("res/dep.dep");
+		runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("WithDependency.hx"), offset: 65});
+		// check messages manually because module file contains awkward absolute path
+		var r = ~/skipping Dependency\(.*dep.dep\)/;
+		Assert.isTrue(messages.exists(message -> r.match(message)));
+	}
 }
 
 class Main {