浏览代码

[display] prioritize module type display when displaying type-hints

closes #7159
Simon Krajewski 7 年之前
父节点
当前提交
45d662c735
共有 2 个文件被更改,包括 16 次插入13 次删除
  1. 14 11
      src/context/display/displayEmitter.ml
  2. 2 2
      tests/display/src/cases/Resuming.hx

+ 14 - 11
src/context/display/displayEmitter.ml

@@ -143,17 +143,20 @@ let display_module_type ctx mt p = match ctx.com.display.dms_kind with
 
 let rec display_type ctx t p =
 	let dm = ctx.com.display in
-	match dm.dms_kind with
-	| DMHover ->
-		let ct = completion_type_of_type ctx t in
-		let ci = make_ci_expr (mk (TConst TNull) t p) (t,ct) in
-		raise_hover ci p
-	| _ ->
-		try display_module_type ctx (module_type_of_type t) p
-		with Exit -> match follow t,follow !t_dynamic_def with
-			| _,TDynamic _ -> () (* sanity check in case it's still t_dynamic *)
-			| TDynamic _,_ -> display_type ctx !t_dynamic_def p
-			| _ -> ()
+	try
+		display_module_type ctx (module_type_of_type t) p
+	with Exit ->
+		match follow t,follow !t_dynamic_def with
+		| _,TDynamic _ -> () (* sanity check in case it's still t_dynamic *)
+		| TDynamic _,_ -> display_type ctx !t_dynamic_def p
+		| _ ->
+			match dm.dms_kind with
+			| DMHover ->
+				let ct = completion_type_of_type ctx t in
+				let ci = make_ci_expr (mk (TConst TNull) t p) (t,ct) in
+				raise_hover ci p
+			| _ ->
+				()
 
 let check_display_type ctx t p =
 	let add_type_hint () =

+ 2 - 2
tests/display/src/cases/Resuming.hx

@@ -15,8 +15,8 @@ class Resuming extends DisplayTestCase {
 	typedef TUnfinished = Arr{-1-}ay<{signatures: Ar{-2-}ray<St{-3-}ring
 	**/
 	function testAutoClose1() {
-		eq("Array<{ signatures : Array<String> }>", type(pos(1)));
-		eq("Array<String>", type(pos(2)));
+		eq("Array<Array.T>", type(pos(1)));
+		eq("Array<Array.T>", type(pos(2)));
 		eq("String", type(pos(3)));
 	}
 }