Browse Source

[display] make sure .macro.hx display files are processed

Simon Krajewski 6 years ago
parent
commit
e19319cc79
2 changed files with 18 additions and 4 deletions
  1. 9 4
      src/compiler/displayOutput.ml
  2. 9 0
      src/compiler/main.ml

+ 9 - 4
src/compiler/displayOutput.ml

@@ -658,6 +658,11 @@ let handle_display_argument com file_pos pre_compilation did_something =
 			pmax = pos;
 		}
 
+type display_path_kind =
+	| DPKNormal of path
+	| DPKMacro of path
+	| DPKNone
+
 let process_display_file com classes =
 	let get_module_path_from_file_path com spath =
 		let rec loop = function
@@ -681,7 +686,7 @@ let process_display_file com classes =
 	in
 	match com.display.dms_display_file_policy with
 		| DFPNo ->
-			None
+			DPKNone
 		| dfp ->
 			if dfp = DFPOnly then begin
 				classes := [];
@@ -695,14 +700,14 @@ let process_display_file com classes =
 					| [name;"macro"] ->
 						(* If we have a .macro.hx path, don't add the file to classes because the compiler won't find it.
 						   This can happen if we're completing in such a file. *)
-						(fst path,name)
+						DPKMacro (fst path,name)
 					| [name] ->
 						classes := path :: !classes;
-						path
+						DPKNormal path
 					| _ ->
 						assert false
 				in
-				Some path
+				path
 			| None ->
 				if not (Sys.file_exists real) then failwith "Display file does not exist";
 				(match List.rev (ExtString.String.nsplit real Path.path_sep) with

+ 9 - 0
src/compiler/main.ml

@@ -1016,6 +1016,15 @@ try
 	end else begin
 		(* Actual compilation starts here *)
 		let tctx = create_typer_context ctx !native_libs in
+		let display_file_dot_path = match display_file_dot_path with
+			| DPKMacro path ->
+				ignore(load_display_module_in_macro tctx (Some path) true);
+				Some path
+			| DPKNormal path ->
+				Some path
+			| DPKNone ->
+				None
+		in
 		begin try
 			do_type tctx !config_macros !classes;
 		with TypeloadParse.DisplayInMacroBlock ->