Bladeren bron

[display] fix abstract field hover, closes #7272 (#7312)

* [display] fix scope for abstract fields always being static in hover

fixes part of #7272

* [display] also turn "_new" into "new" for hover

closes #7272
Jens Fischer 7 jaren geleden
bovenliggende
commit
7f4595f84d
1 gewijzigde bestanden met toevoegingen van 17 en 1 verwijderingen
  1. 17 1
      src/typing/typeloadFields.ml

+ 17 - 1
src/typing/typeloadFields.ml

@@ -603,7 +603,23 @@ let bind_type (ctx,cctx,fctx) cf r p =
 
 let check_field_display ctx fctx c cf =
 	if fctx.is_display_field then begin
-		let scope = if fctx.is_static then CFSStatic else if fctx.field_kind = FKConstructor then CFSConstructor else CFSMember in
+		let scope, cf = match c.cl_kind with
+			| KAbstractImpl _ ->
+				if Meta.has Meta.Impl cf.cf_meta then
+					(if cf.cf_name = "_new" then 
+						CFSConstructor, {cf with cf_name = "new"}
+					else
+						CFSMember, cf)
+				else
+					CFSStatic, cf;
+			| _ ->
+				(if fctx.is_static then
+					CFSStatic
+				else if fctx.field_kind = FKConstructor then
+					CFSConstructor
+				else
+					CFSMember), cf;
+		in
 		let origin = match c.cl_kind with
 			| KAbstractImpl a -> Self (TAbstractDecl a)
 			| _ -> Self (TClassDecl c)