Browse Source

[display] use NotJsonType for toplevel expected type

closes #7178
Simon Krajewski 7 years ago
parent
commit
d7daf5c0c9
2 changed files with 9 additions and 5 deletions
  1. 4 4
      src/core/displayTypes.ml
  2. 5 1
      src/typing/typerDisplay.ml

+ 4 - 4
src/core/displayTypes.ml

@@ -67,7 +67,7 @@ module CompletionResultKind = struct
 	type t =
 		| CRField of CompletionItem.t * pos
 		| CRStructureField
-		| CRToplevel of Type.t option
+		| CRToplevel of (CompletionItem.CompletionType.t * CompletionItem.CompletionType.t) option
 		| CRMetadata
 		| CRTypeHint
 		| CRExtends
@@ -108,9 +108,9 @@ module CompletionResultKind = struct
 			| CRToplevel t ->
 				let args = match t with
 					| None -> None
-					| Some t -> Some (jobject [
-						"expectedType",generate_type ctx t;
-						"expectedTypeFollowed",generate_type ctx (follow t)
+					| Some(ct1,ct2) -> Some (jobject [
+						"expectedType",CompletionItem.CompletionType.to_json ctx ct1;
+						"expectedTypeFollowed",CompletionItem.CompletionType.to_json ctx ct2;
 					])
 				in
 				2,args

+ 5 - 1
src/typing/typerDisplay.ml

@@ -128,7 +128,11 @@ let raise_toplevel ctx with_type po p =
 		| WithType t -> Some t
 		| _ -> None
 	in
-	raise_fields (DisplayToplevel.collect ctx (Some p) with_type) (CRToplevel t) po
+	let ct = match t with
+		| None -> None
+		| Some t -> Some (completion_type_of_type ctx t,completion_type_of_type ctx (follow t))
+	in
+	raise_fields (DisplayToplevel.collect ctx (Some p) with_type) (CRToplevel ct) po
 
 let rec handle_signature_display ctx e_ast with_type =
 	ctx.in_display <- true;