RefClass (RefManager refManager, UElement uElement) { while (uElement != null && !(uElement instanceof UClass)) { uElement = uElement.getUastParent(); } if (uElement != null) { RefElement reference = refManager.getReference(uElement.getSourcePsi()); return reference instanceof RefClass refClass ? refClass : null; } return null; }