Browse Source

[display] fix typedef to anon origin

Simon Krajewski 7 years ago
parent
commit
60e4983b31
2 changed files with 12 additions and 2 deletions
  1. 6 1
      src/context/display/displayFields.ml
  2. 6 1
      src/typing/typerDisplay.ml

+ 6 - 1
src/context/display/displayFields.ml

@@ -161,7 +161,12 @@ let collect ctx e_ast e dk with_type p =
 								| Some c -> should_access c cf true
 								| Some c -> should_access c cf true
 							in
 							in
 							Self (TAbstractDecl a),check
 							Self (TAbstractDecl a),check
-						| _ -> AnonymousStructure an,true
+						| _ ->
+							let origin = match t with
+								| TType(td,_) -> Self (TTypeDecl td)
+								| _ -> AnonymousStructure an
+							in
+							origin,true
 					in
 					in
 					if check then PMap.add name (make_ci_class_field (CompletionClassField.make cf CFSMember origin true) cf.cf_type) acc
 					if check then PMap.add name (make_ci_class_field (CompletionClassField.make cf CFSMember origin true) cf.cf_type) acc
 					else acc
 					else acc

+ 6 - 1
src/typing/typerDisplay.ml

@@ -43,7 +43,12 @@ let completion_item_of_expr ctx e =
 		| TField(_,FEnum(en,ef)) -> of_enum_field e (Self (TEnumDecl en)) ef
 		| TField(_,FEnum(en,ef)) -> of_enum_field e (Self (TEnumDecl en)) ef
 		| TField(e1,FAnon cf) ->
 		| TField(e1,FAnon cf) ->
 			begin match follow e1.etype with
 			begin match follow e1.etype with
-				| TAnon an -> of_field e (AnonymousStructure an) cf CFSMember
+				| TAnon an ->
+					let origin = match e1.etype with
+						| TType(td,_) -> Self (TTypeDecl td)
+						| _ -> AnonymousStructure an
+					in
+					of_field e origin cf CFSMember
 				| _ -> itexpr e
 				| _ -> itexpr e
 			end
 			end
 		| TTypeExpr mt -> make_ci_type (CompletionModuleType.of_module_type mt) ImportStatus.Imported (Some e.etype) (* TODO *)
 		| TTypeExpr mt -> make_ci_type (CompletionModuleType.of_module_type mt) ImportStatus.Imported (Some e.etype) (* TODO *)